Works for me
In C
Code:
#include <stdio.h>
#include <string.h>
typedef unsigned char u_char;
void gamespyxor(u_char *data, int len) {
u_char gamespy[] = "gamespy",
*gs;
for(gs = gamespy; len; len--, gs++, data++) {
if(!*gs) gs = gamespy;
*data ^= *gs;
}
}
int main ( ) {
u_char enc[1000];
u_char dec[1000];
char msg[] = "\\unok\\cd\\81dc9bdb52d04dc20036dbd8313ed055\\skey\\1257\\errmsg\\Invalid CD Key";
int len = strlen(msg);
printf("The encrypt is the decrypt\n");
printf( "%s\n", msg );
memcpy( enc, msg, len );
gamespyxor( enc, len );
memcpy( dec, enc, len );
gamespyxor( dec, len );
printf( "%s\n", dec );
return 0;
}
$ gcc foo.c && ./a.exe
The encrypt is the decrypt
\unok\cd\81dc9bdb52d04dc20036dbd8313ed055\skey\1257\errmsg\Invalid CD Key
\unok\cd\81dc9bdb52d04dc20036dbd8313ed055\skey\1257\errmsg\Invalid CD Key
In PHP
PHP Code:
<?php
function x_Encrypt($string, $key)
{
for($i=0; $i<strlen($string); $i++)
{
for($j=0; $j<strlen($key); $j++)
{
$string[$i] = $string[$i]^$key[$j];
}
}
return $string;
}
$string = '\\unok\\cd\\81dc9bdb52d04dc20036dbd8313ed055\\skey\\1257\\errmsg\\Invalid CD Key';
$key = 'gamespy';
echo "The encrypt is the decrypt\n";
echo $string,"\n";
echo x_Encrypt(x_Encrypt($string, $key), $key);
?>
Code:
C:\Program Files\php>php -f \gash\foo.php
The encrypt is the decrypt
\unok\cd\81dc9bdb52d04dc20036dbd8313ed055\skey\1257\errmsg\Invalid CD Key
\unok\cd\81dc9bdb52d04dc20036dbd8313ed055\skey\1257\errmsg\Invalid CD Key