public int encrypt(byte[] raw, int offset, int size) { // reserve checksum size += 4; if (_static) { // reserve for XOR "key" size += 4; // padding size += 8 - (size % 8); NewCrypt.encXORPass(raw, offset, size, rnd.Next()); _staticCrypt.crypt(raw, offset, size); _static = false; } else { // padding size += 8 - (size % 8); NewCrypt.appendChecksum(raw, offset, size); _crypt.crypt(raw, offset, size); } return(size); }
/** * Packet is first XOR encoded with <code>key</code> Then, the last 4 bytes are overwritten with the the XOR "key". Thus this assume that there is enough room for the key to fit without overwriting data. * @param raw The raw bytes to be encrypted * @param key The 4 bytes (int) XOR key */ public static void encXORPass(byte[] raw, int key) { NewCrypt.encXORPass(raw, 0, raw.Length, key); }