// XiliCrypt.cpp : Defines the entry point for the console application. // #include "stdafx.h" // Xilosoft Cryptor.cpp : Defines the entry point for the console application. // #include "stdafx.h" char Encrypted[] = "4B1FEC793DACE5A9BC0BBFF6983BDF8AC083ABC53F04B3B4252AA9E8A81F99EFED4BB30FA23BD4"; char Key[] = "abcdefghijkl"; unsigned long keyhex[3]; unsigned long ByteKey,Key2Status,Key3Status; unsigned long hextoint(const char *string) { unsigned long r=0; const char *c=string; while (*c) { if (*c>='0' && *c<='9') r=(r*16)+(*c-'0'); else if (*c>='a' && *c<='f') r=(r*16)+(*c-'a')+10; else if (*c>='A' && *c<='F') r=(r*16)+(*c-'A')+10; ++c; }; return r; }; void InitCrypt(LPSTR Key) { int i,j,k; char TempKey[16] = {0}; char TempByte = 0; i = strlen(Key); j = 0; k = i; strcpy(TempKey,Key); while (i < 12) { TempKey[i] = TempKey[j]; if (j == k) { j = 0; } i++; j++; } for (i=0;i<3;i++) { k = 3; TempByte = 0; for (j=0;j<2;j++) { TempByte = TempKey[(i*4)+k]; TempKey[(i*4)+k] = TempKey[(i*4)+j]; TempKey[(i*4)+j] = TempByte; k--; } } memmove(&keyhex[0], TempKey,4); memmove(&keyhex[1], TempKey+4,4); memmove(&keyhex[2], TempKey+8,4); }; char CryptByte(char ByteToCrypt) { unsigned long ANDResult; ByteKey = 0; Key2Status = (keyhex[1] & 1); Key3Status = (keyhex[2] & 1); for (int i = 0;i<8;i++) { ANDResult = keyhex[0] & 1; if (!ANDResult) { keyhex[0] = keyhex[0] / 2 & 0x7FFFFFFF; ANDResult = keyhex[2] & 1; if (!ANDResult) { keyhex[2] = (keyhex[2] >> 1) & 0x0FFFFFFF; Key3Status = 0; } else { keyhex[2] = ((keyhex[2] ^ 0x10000002) >> 1) | 0xF0000000; Key3Status = 1; } } else { keyhex[0] = ((keyhex[0] ^ 0x80000062) >> 1) | 0x80000000; ANDResult = (keyhex[1] & 1); if (!ANDResult) { keyhex[1] = (keyhex[1] >> 1) & 0x3FFFFFFF; Key2Status = 0; } else { keyhex[1] = ((keyhex[1] ^ 0x40000020) >> 1) | 0xC0000000; Key2Status = 1; } } ByteKey += ByteKey; ByteKey &= 65535; ByteKey |= (Key2Status ^ Key3Status); } ByteToCrypt ^= ByteKey; return ByteToCrypt; } LPSTR CryptString(LPSTR lpString,LPSTR Key,BOOL IsHexString) { InitCrypt(Key); char CurrentByte[4] = {0}; char CurrentBytes[4] = {0}; char TempString[256] = {0}; int i,j; i = strlen(lpString); if (IsHexString) { for (j = 0;j<(i/2);j++) { memcpy(&CurrentBytes,&lpString[j*2],2); memset(&CurrentByte,0,4); CurrentByte[0] = (char)hextoint(CurrentBytes); lpString[j] = CryptByte(CurrentByte[0]); } for (j=i/2;j