Code: Select all
public static void Decrypt(
ref byte[] data,
int nStartOffset,
int nSizeToDecrypt,
char[] randomKey)
{
int oKey [16] = { 0x55, 0x52, 0x33, 0x48, 0x63, 0x6A, 0x37, 0x6E, 0x64, 0x68, 0x38, 0x59, 0x6E, 0x6F, 0x74, 0x39 };
int num1 = 0;
for (int index1 = nStartOffset; index1 < nStartOffset + nSizeToDecrypt; ++index1)
{
int index2 = num1 % oKey .Length;
int index3 = num1 % randomKey.Length;
byte num2 = (byte) ((uint) (byte) ((uint) data[index1] - (uint) (byte) randomKey[index3]) ^ (uint) (byte) oKey [index2]);
data[index1] = num2;
++num1;
}
}
input should be
ref byte[] data, -- source file
int nStartOffset, -- 16
int nSizeToDecrypt, -- 64
char[] randomKey) -- first 16 bytes of the file
example
random key is E1 C9 16 93 99 04 7D 4F D5 43 28 57 E1 F4 DB 00
first few bytes of the file
DF E2 7D A3 DC
the function does this
(0xDF - 0xE1) ^ 0x55 = 0xAB
2nd byte
(0xE2 - 0xC9) ^ 0x52 = 0x4B