PHP Code:
<?
function hex2bin($data) {
$len = strlen($data);
return pack("H" . $len, $data);
}
function bin2hex2($data) {
return unpack("H*",$data);
}
function check_key($input){
$iv = "qe3jigneqfrgnqw2egfmas4qetjkn5lg";
$key = "589752d5b0f4217747bd721111be9057";
$text = hex2bin($input);
$domain = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
return $domain;
}
function make_key($input) {
$iv = "qe3jigneqfrgnqw2egfmas4qetjkn5lg";
$key = "589752d5b0f4217747bd721111be9057";
$domain = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $input, MCRYPT_MODE_ECB, $iv);
$key = bin2hex2($domain);
return $key[1];
}
$key = make_key($_REQUEST['domain']);
echo "Key is ".$key."<br /><br />\n\n";
echo "Decode Check: ".check_key($key);
?>
page.php?domain=test.com