public static byte[] RC4_do(byte[] arg8, int reclenth)
{
byte[] srdata = arg8.Take(reclenth).ToArray();
Console.WriteLine("传入的长度:{0}", srdata.Length);
if (reclenth < 4)
{
byte[] ret = RC4_DE(srdata, 0, reclenth);
return ret;
}
byte[] aa = srdata.Take(4).ToArray();
int lenth = aa.Length;
Console.WriteLine("取前 {0} 个字节{1}", lenth, aa);
byte[] lenthaa = RC4_DE(aa, 0, aa.Length);
byte[] bb = srdata.Skip(4).ToArray();
Console.WriteLine("剩余{0}个字节 {1}", bb.Length, bb);
byte[] data = RC4_DE(bb, 0, bb.Length);
return data;
}
static int b_d = 0;
static int c_d = 0;
static byte[] a_d = { 30, 206, 110, 131, 100, 117, 36, 24, 243, 230, 79, 193, 41, 9, 101, 234, 232, 216, 248, 48, 91, 150, 121, 148, 39, 103, 251, 106, 176, 203, 45, 194, 4, 208, 58, 43, 3, 118, 228, 242, 213, 47, 49, 169, 67, 179, 75, 204, 56, 168, 88, 65, 128, 86, 190, 40, 31, 89, 102, 238, 236, 215, 122, 240, 237, 235, 71, 76, 13, 78, 171, 132, 250, 64, 233, 37, 139, 57, 222, 44, 220, 120, 33, 90, 140, 144, 224, 6, 160, 125, 135, 174, 61, 107, 18, 83, 175, 50, 153, 142, 72, 136, 218, 127, 130, 80, 184, 221, 99, 28, 95, 197, 27, 146, 126, 84, 32, 116, 188, 81, 54, 249, 152, 202, 137, 231, 73, 96, 69, 159, 225, 53, 85, 154, 183, 16, 180, 59, 22, 185, 5, 55, 20, 210, 245, 113, 209, 246, 46, 200, 189, 92, 205, 35, 60, 226, 155, 252, 82, 23, 239, 227, 156, 195, 217, 77, 38, 186, 11, 51, 170, 199, 19, 29, 158, 145, 1, 10, 108, 129, 119, 181, 187, 164, 62, 143, 26, 157, 8, 191, 12, 70, 255, 14, 178, 162, 211, 112, 66, 133, 207, 105, 68, 52, 94, 0, 172, 173, 196, 123, 161, 17, 138, 149, 212, 111, 93, 34, 223, 229, 63, 147, 219, 182, 114, 7, 244, 109, 141, 177, 165, 15, 124, 115, 151, 192, 98, 167, 21, 163, 25, 2, 241, 253, 104, 214, 166, 134, 97, 42, 87, 198, 74, 247, 254, 201 };
public static byte[] RC4_DE(byte[] arg8, int arg9, int arg10)
{
int v0 = arg9 + arg10;
if (arg8 != null && arg9 >= 0 && arg10 >= 0 && v0 <= arg8.Length)
{
while (arg9 < v0)
{
int v1 = arg8[arg9];
b_d = b_d + 1 & 255;
c_d = (a_d[b_d] & 255) + c_d & 255;
byte v2 = a_d[b_d];
a_d[b_d] = a_d[c_d];
a_d[c_d] = v2;
arg8[arg9] = ((byte)(v1 ^ a_d[(a_d[b_d] & 255) + (a_d[c_d] & 255) & 255]));
++arg9;
}
}
byte[] dest = new byte[arg8.Length];
Array.Copy(arg8, dest, arg8.Length);
return dest;
}
|