public byte[] HMAC_SHA1(byte[] Key, byte[] Message)
{
byte[] K = new byte[0x40];
byte[] opad = new byte[20 + 0x40];
byte[] ipad = new byte[Message.Length + 0x40];
Array.Copy(Key, K, 16);
for (int i = 0; i < 64; i++)
{
opad[i] = (byte)(K[i] ^ 0x5C);
ipad[i] = (byte)(K[i] ^ 0x36);
}
// Copy Buffer
Array.Copy(Message, 0, ipad, 0x40, Message.Length);
// Get First Hash
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
byte[] Hash1 = sha.ComputeHash(ipad);
// Copy to OPad
Array.Copy(Hash1, 0, opad, 0x40, 20);
return sha.ComputeHash(opad);
}
public void RC4(ref Byte[] bytes, Byte[] key)
{
Byte[] s = new Byte[256];
Byte[] k = new Byte[256];
Byte temp;
int i, j;
for (i = 0; i < 256; i++)
{
s[i] = (Byte)i;
k[i] = key[i % key.GetLength(0)];
}
j = 0;
for (i = 0; i < 256; i++)
{
j = (j + s[i] + k[i]) % 256;
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
i = j = 0;
for (int x = 0; x < bytes.GetLength(0); x++)
{
i = (i + 1) % 256;
j = (j + s[i]) % 256;
temp = s[i];
s[i] = s[j];
s[j] = temp;
int t = (s[i] + s[j]) % 256;
bytes[x] ^= s[t];
}
}