I have seen this several times, but not quite exactly how I am going to ask about it here ... I hope everything is all right with you.
Basically, I have this script that works fine and prints my result without a hitch:
$algorithm = MCRYPT_BLOWFISH;
$mode = MCRYPT_MODE_CFB;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($algorithm, $mode), MCRYPT_DEV_URANDOM);
$key = 'Wassup';
$data = 'I am a guy';
$enc_data = rtrim(mcrypt_encrypt($algorithm,$key,$data,$mode,$iv));
$plain_text = base64_encode($enc_data);
echo $plain_text . "\n";
$enc_data = base64_decode($plain_text);
$decoded = mcrypt_decrypt($algorithm,$key,$enc_data,$mode,$iv);
echo $decoded;
It's fine. NOW ... instead of immediately outputting what I insert, I try to store this information in my database, which will be decrypted later.
I can see the encrypted row in my table row: 6m3D5qSrfz3w6pKuuybs. So, I'm sure everything is going fine ...
and when I request it, it looks the same, but now when I decode and decrypt, I get something like: ÝÄ / $ ÍñËt05883700
The table field is configured as VARCHAR (255) utf8_general_ci. Where is the problem?