$mcrypt_key = "24 character key goes here";
$mcrypt_module = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, "");
srand ((float) microtime() * 1000000);
$mcrypt_iv = mcrypt_create_iv(mcrypt_get_iv_size($mcrypt_module), MCRYPT_RAND);
mcrypt_generic_init ($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$art = mcrypt_generic($mcrypt_module, $art);
$art = base64_encode($art);
$mcrypt_iv = base64_encode($mcrypt_iv);
mcrypt_generic_end ($mcrypt_module);
The data is stored in a mySQL database, then retrieved later.
To decrypt:
$mcrypt_key = "24 character key goes here";
$mcrypt_module = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, "");
$art = base64_decode($art);
$mcrypt_iv = base64_decode($mcrypt_iv);
mcrypt_generic_init ($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$art = mdecrypt_generic($mcrypt_module, $art);
mcrypt_generic_end ($mcrypt_module);
Only the first 8 characters of the encrypted string are decrypted properly.
-- mark hurty | mark@hurty.com | 309.764.0911
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php