Quote:
Originally posted by magnatique
I need to encrypt a string in the status bar so that I can pass
?string=798&Wwehkl3elkjdslade
instead of something like
?info1=true&info2=false&info3=true
NOW....
I need to know what encrypting language I need to use..
I was gonna use mcrypt... but it seems des and all the other encrypting things I used create some weird characters... I need to pass it through the browser address bar, so it needs to be numbers and letters...
can anyone guide me with this please?
|
encrypt it with mcrytp, the use bin2hex and pass the hex value .. then use hex2bin before you unencrypt it
here .. bin2hex is built in
function encrypt($key, $data)
{
$plain_text = trim($data);
$iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$c_t = mcrypt_encrypt (MCRYPT_CAST_256, $key, $plain_text, "cfb", $iv);
return trim(chop(base64_encode($c_t)));
}
function decrypt($key, $c_t)
{
$c_t = trim(chop(base64_decode($c_t)));
$iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$p_t = mcrypt_decrypt (MCRYPT_CAST_256, $key, $c_t, "cfb", $iv);
return trim(chop($p_t));
}
function hex2bin($data) {
$len = strlen($data);
for ($i=0;$i<$len;$i+=2) {
$newdata .= pack("C",hexdec(substr($data,$i,2)));
}
return $newdata;
}