Thread: little php help
View Single Post
Old 10-12-2009, 04:11 PM  
quantum-x
Confirmed User
 
quantum-x's Avatar
 
Join Date: Feb 2002
Location: ICQ: 251425 Fr/Au/Ca
Posts: 6,863
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
quantum-x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote