Skip to content

Instantly share code, notes, and snippets.

@hasherezade
Created March 7, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasherezade/ed8366cf0fd007a2a416f2531d5251e4 to your computer and use it in GitHub Desktop.
Save hasherezade/ed8366cf0fd007a2a416f2531d5251e4 to your computer and use it in GitHub Desktop.
void lockcrypt::level2_crypt(void *buf, size_t buf_size, void *key, size_t key_size)
{
size_t dwsize = buf_size >> 2;
for (size_t i = 4, k = 0; i < buf_size - 6; i += 4, k +=4) {
if (k > KEY_SIZE) {
k = 0;
}
DWORD *dwlist = (DWORD *) ((ULONGLONG)buf + i);
DWORD *keydw = (DWORD *) ((ULONGLONG)key + k);
DWORD inp = *dwlist;
inp = rol32(inp, 5);
DWORD out = inp ^ (*keydw);
out = bswap32(out);
(*dwlist) = out;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment