i have the below code for encryption , but the problem is its not decrypting the data as reqired
$salt ='whatever_you_want';
$en= simple_encrypt('data');
echo simple_decrypt($en);
function simple_encrypt($text)
{
global $salt;
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_CBC, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND))));
}
function simple_decrypt($text)
{
global $salt;
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_CBC, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND)));
}
the problem is it encrypts and each time it generates a new encrypted text as i want it to happen but the decryption is not happening
im getting something like this
%B…*¥ Þ‚á+ËU:L|(øŽ«úÐ9ÇvÉêÿ¿Ïg
any insight would be appreciated guys :)