16,471
社区成员
发帖
与我相关
我的任务
分享
void test_xor(unsigned char *src_buf, unsigned char *dest_buf, int length, unsigned long factor)
{
ASSERT(src_buf && dest_buf);
ASSERT(length % sizeof(unsigned long) == 0);
int count = length / sizeof(unsigned long);
unsigned long *src_ptr = (unsigned long *)src_buf;
unsigned long *dest_ptr = (unsigned long *)dest_buf;
for (int i = 0; i < count; ++i)
{
dest_ptr[i] = src_ptr[i] ^ factor;
}
}
#define BUF_SIZE 256
unsigned char src[BUF_SIZE];
unsigned char dest[BUF_SIZE];
test_xor(src, dest, BUF_SIZE, 0x12011201);
WORD value = 0x1201;
PWORD src = (PWORD)SrcData;
PWORD dest = (PWORD)DestData;
int length = (int)DataLength/2;
for (int i=0; i<length; i++)
{
dest[i] = src[i] ^ value;
}