Created
May 10, 2010 01:52
-
-
Save jeedee/395573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assume our encryption key is a array of 9 bytes containing the ASCII values "NexonInc." (Default Dark Ages Encryption Key) | |
key = {4E 65 78 6F 6E 49 6E 63 2E} | |
/* This function encrypts or decrypts our packets. Sequence is the packet SEQUENCE number, array is the pointer to the packet DATA, start is WHERE in the array to start and count is HOW MANY bytes to encrypt or decrypt. */ | |
int EncryptDecrypt(byte sequence, byte* array, int start, int count) | |
{ | |
for(int i = 0; i < count; i++) | |
{ | |
// XOR by Key, Sequence, and Iteration | |
array[start + i] = (byte)(array[start + i] ^ key[i % 9] ^ sequence ^ (i / 9)); | |
// Xor Cancel Check | |
if((i / 9) == sequence) | |
{ | |
array[start + i] = (byte)(array[start + i] ^ sequence); | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment