-
-
Save hshrzd/578770a5261d422e1e112cdd3d8ed75e 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
int __stdcall calc_hash(char *name) | |
{ | |
int next_chunk; | |
int hash; | |
for ( hash = HASH_INIT; ; hash = next_chunk + 33 * hash ) | |
{ | |
next_chunk = *name++; | |
if ( !next_chunk ) | |
break; | |
} | |
return hash; | |
} |
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
void __stdcall decrypt_buf(BYTE *data, BYTE *key, unsigned int size) | |
{ | |
BYTE key_stream[512]; | |
int j; | |
char next; | |
int i; | |
int v6 = 0; | |
int v4 = 0; | |
for ( i = 0; i < 256; ++i ) | |
{ | |
key_stream[i + 256] = i; | |
key_stream[i] = key[i % size]; | |
} | |
for ( i = 0; i < 256; ++i ) | |
{ | |
v6 = (key_stream[i] + v6 + key_stream[i + 256]) % 256; | |
next = key_stream[v6 + 256]; | |
key_stream[v6 + 256] = key_stream[i + 256]; | |
key_stream[i + 256] = next; | |
} | |
v6 = 0; | |
for ( j = 0; j < DATA_SIZE; ++j ) | |
{ | |
i = (i + 1) % 256; | |
v6 = (v6 + key_stream[i + 256]) % 256; | |
next = key_stream[v6 + 256]; | |
key_stream[v6 + 256] = key_stream[i + 256]; | |
key_stream[i + 256] = next; | |
v4 = (key_stream[v6 + 256] + key_stream[i + 256]) % 256; | |
data[j] ^= key[j % size]; | |
data[j] ^= key_stream[v4 + 256]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment