int xorkey[] =
{
0x41, 0xB6, 0x7F, 0x58, 0x38,0x0C, 0xF0, 0x2D, 0x7B, 0x39,
0x08, 0xFE, 0x21, 0xBB, 0x41,0x58
};
//加密函数将会直接修改传入的pbData内存数据,使用时请注意
void __fastcall xor_encrypt(LPBYTE pbData, int nSize)
{
BYTE byTemp = 0;
if (pbData)
{
for (int i = 0; i < nSize; ++i)
{
pbData[i] = pbData[i] ^ byTemp + xorkey[i & 15];
byTemp = pbData[i];
}
}
}
void __fastcall xor_decrypt(LPBYTE pbData, int nSize)
{
BYTE byPrev = 0;
BYTE byTemp = 0;
if (pbData)
{
for (int i = 0; i < nSize; ++i)
{
byPrev = pbData[i];
pbData[i] = pbData[i] ^ byTemp + xorkey[i & 15];
byTemp = byPrev;
}
}
}
|