Skip to content

Instantly share code, notes, and snippets.

@jeedee
Created May 10, 2010 01:52
Show Gist options
  • Save jeedee/395573 to your computer and use it in GitHub Desktop.
Save jeedee/395573 to your computer and use it in GitHub Desktop.
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