I am encrypting the values and sending an encrypted value on another page with the help of URL and there I am decrypting values but decrypted value is not displaying properly. I am getting output like \j3�B��9[r�m�N�B~=��:�nc.�
Would you help me in this?
Index.php
$input =5;
$encrypted = encryptIt( $input );
echo $encrypted;
function encryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );
}
echo "<a href='decry.php?user_id=$encrypted'>Click here</a>";
decry.php
$id=$_GET['user_id'];
$decrypted = decryptIt( $id );
echo $decrypted;
function decryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
return( $qDecoded );
}