Encryption functions in PHP output unexpected characters
I use simple_encrypt to store some sensitive information in the cookie.
When I try to decrypt it with simple_decrypt, it doesn't give the same
string. When I try to output that string after simple_decrypt I get chars
with symbols like �. What's wrong?
$salt ='sososo222xxxXXsder3FVRE';
function simple_encrypt($text)
{
global $salt;
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text,
MCRYPT_MODE_ECB);
}
function simple_decrypt($text)
{
global $salt;
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, $text,
MCRYPT_MODE_ECB);
}
EDIT: I use setcookie("rt", simple_encrypt($a['rt']), time()+(3600 * 24 *
365)); to store cookie.
No comments:
Post a Comment