Hello,
I am having much trouble with getting mcyrpt to decrypt info for me. It just spits back the encrypted string at me. I have tried many an example posted on this site, others sites, as well as a bunch of my own creation of course.
Anyone have any suggestions?......., please do not suggest "See the Mcrypt Reference on PHP.net", as I have already been through there many a time. One sample is below:
PHP
echo('This is the test to see if mycrypt works<br/><br/>');
$key = '1233543565784534534';
$data = 'maynard';
echo('Gonna try to encrypt it now<br/><br/>');
$mcrypt_module = mcrypt_module_open('blowfish', '', MCRYPT_MODE_ECB, '');
//$mcrypt_module = mcrypt_module_open('tripledes', '', 'ecb', '');
//getting initialization vector
$mcrypt_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($mcrypt_mo
dule), MCRYPT_RAND);
echo('Initialization vector is:'.$mcrypt_iv.'<br/>');
//getting key size for this encryption mode
$key_size = mcrypt_enc_get_key_size($mcrypt_module);
echo('Key size is:'.$key_size.'<br/>');
$key = substr(md5($key), 0, $key_size);
echo('Actuall key after md5 is:'.$key.'<br/><br/>');
mcrypt_generic_init($mcrypt_module,$key,$mcrypt_iv
);
$encrypted_data = mcrypt_generic($mcrypt_module, $data);
// Terminate encryption handler
mcrypt_generic_deinit($mcrypt_module);
// Initialize encryption module for decryption
mcrypt_generic_init($mcrypt_module, $key, $mcrypt_iv);
// Decrypt encrypted string
$decrypted_data = mdecrypt_generic($mcrypt_module, $encrypted_data);
// Terminate decryption handle and close module
mcrypt_generic_deinit($mcrypt_module);
mcrypt_module_close($mcrypt_module);
// Show string
echo('Here is the data un-encrypted:'.$data.'<br/>');
echo('Here is the encrypted data:'.$encrypted_data.'<br/>');
echo('Here is my decrypted data:'.trim($decrypted_data).'<br/>');
HTML
This is the test to see if mycrypt works
Gonna try to encrypt it now
Initialization vector is:äYz•Î1
Key size is:56
Actuall key after md5 is:a69961fcf9e6c7005624eef5e7c5d9c6
Here is the datad un-encrypted:maynard
Here is the encrypted_data:yȇ”€\…
Here is my decrypted data:yȇ”€\…
????????????????