// unsigned 32 bit integer (dword) #if defined(_MSC_VER) && !defined(uint32_t)
#if (_MSC_VER < 1300)
typedef unsigned int uint32_t;
#else
typedef unsigned __int32 uint32_t;
#endif
#else
#include <stdint.h>
#endif
const int hash_skeys[4][2] = {
{ 213119, 2529077 },
{ 213247, 2529089 },
{ 213203, 2529589 },
{ 213821, 2529997 }
};
const char hex_digit[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
void encrypt(char *src, char *dst)
{
int i = 0, j = 0;
char key[0x10];
char buff[0x10];
char hexbuff[0x21];
uint32_t* key_dwords = (uint32_t*)key;
memset(&key, 0, sizeof(key));
memset(&buff, 0, sizeof(buff));
memset(&hexbuff, 0, sizeof(hexbuff));
strncpy(key, src, sizeof(key));
strncpy(buff, src, sizeof(buff));
for(i = 0; i < 4; i++)
key_dwords = key_dwords * hash_skeys[0] + hash_skeys[1];
buff[0] = buff[0] ^ key[0];
for(i = 1; i < 0x10; i++)
buff = buff ^ buff[i-1] ^ key;
for(i = 0; i < 0x10; i++) {
j = buff != 0 ? buff : 102;
hexbuff[i*2] = hex_digit[j >> 4 & 0x0f];
hexbuff[i*2 + 1] = hex_digit[j & 0x0f];
}
//hexbuff[0x20] = 0;
sprintf(dst, "0x%s", hexbuff);
}