rc4

#include 
#include 



static   UCHAR g_DeCryptKey[48] = {0xDB, 0x22, 0x98, 0x90, 0x5B, 0xCB, 0x3A, 0x91, 0x92, 0xCA, 0xC4, 0x33, 0x0E, 0xDB, 0xBB, 0x55, 
0x78, 0x02, 0xD8, 0x24, 0x91, 0x5C, 0x25, 0xBB, 0xC4, 0x53, 0xEE, 0xCA, 0x41, 0x60, 0xFB, 0xB8, 
0x61, 0xEF, 0x52, 0x1C, 0xAD, 0xEA, 0xC3, 0x4F, 0xB7, 0xD4, 0x74, 0x69, 0xD6, 0x1B, 0x98, 0xA6};


			


VOID Rc4Init(UCHAR s[256], PUCHAR key, ULONG Len)
{
	ULONG i = 0, j = 0;
	UCHAR k[256] = { 0 };
	UCHAR tmp = 0;

	for (i = 0; i < 256; i++)
	{
		s[i] = (UCHAR)i;
		k[i] = key[i%Len];
	}
	for (i = 0; i<256; i++)
	{
		j = (j + s[i] + k[i]) % 256;
		tmp = s[i];
		s[i] = s[j];//交换s[i]和s[j]
		s[j] = tmp;
	}
}

VOID Rc4Crypt(UCHAR s[256], PUCHAR pData, ULONG Len)
{
	ULONG i = 0, j = 0, t = 0;
	ULONG k = 0;
	UCHAR tmp;

	for (k = 0, i= 0; k

你可能感兴趣的:(rc4)