#ifndef XCYLONS_H
#define XCYLONS_H
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
class XCylons
{
public:
static char* encrypt(unsigned char url_query_md5[2], const char* lcid, uint32_t timestamp, const char* common_key);
static char* decrypt(const char* data, const char* common_key);
};
char* XGorgon::build(const char* url_query, const char* x_ss_stub, const char* unused, int sdkver, int x_khronos)
{
if(url_query == NULL) url_query = "";
if(x_ss_stub == NULL) x_ss_stub = "";
if(unused == NULL) unused = "";
const char* default_str = "00000000";
char result[41] = {0}; //repair
uint8_t query_md5[16];
MD5((const unsigned char *)url_query, strlen(url_query), query_md5);
char *query_md5_str = Utils::toHexStr(query_md5, sizeof(query_md5));
strncat(result, query_md5_str, 8);
free(query_md5_str);
if(strlen(x_ss_stub) == 0){
strncat(result, default_str, strlen(default_str));
}else{
strncat(result, x_ss_stub, 8);
}
if(strlen(unused) == 0){
strncat(result, default_str, strlen(default_str));
}else{
strncat(result, unused, 8);
}
uint8_t sdkver_hex[4];
ByteUtil::toBytes32(sdkver, sdkver_hex, true);
char *sdkver_hex_str = Utils::toHexStr(sdkver_hex, sizeof(sdkver_hex));
strncat(result, sdkver_hex_str, 8);
free(sdkver_hex_str);
uint8_t x_khronos_hex[4];
ByteUtil::toBytes32(x_khronos, x_khronos_hex, true);
char *x_khronos_hex_str = Utils::toHexStr(x_khronos_hex, sizeof(x_khronos_hex));
strncat(result, x_khronos_hex_str, 8);
free(x_khronos_hex_str);
return encrypt(result);
}
static void xdecrypt(uint8_t *data)
{
for (int i = 19; i >= 0; i--) {
data[i] = data[i] ^ 0xFF ^ 20;
data[i] = rBit(data[i]);
data[i] = data[i] ^ data[(i+1)%20];
data[i] = rFourBit(data[i]);
}
}
部分代代码,可以滴我全部