Forum Moderators: coopster
Would someone mind posting an example of how to properly use mcrypt_ecb?
This is the piece of my code I'm having trouble with below.
I've done quite a few searches but keep coming up empty on the proper syntax from start to finish.
$key = "unlock";
$msg = " top secret ";
$crypted = mcrypt_ecb(MCRYPT_LOKI97, $key, $msg, MCRYPT_ENCRYPT);
$crypted = bin2hex($crypted);
echo "$crypted";
mcrypt ecb is depreciated and shouldn't really be used. Instead, you should be using mcrypt_generic [php.net]. There's an example of its use on php.net here recopied below:
$key = "this is a secret key";
$input = "Let us meet at 9 o'clock at the secret place.";
#
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$encrypted_data = mcrypt_generic($td, $input);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
echo $encrypted_data;
Good luck! :)
(whew!)
No chance there is a way I can call on variables from a previous page is there?
or do I have to merge these two pages into one (Which I would really hate to do it was difficult enough getting them to work all by themselves)
I thought I could encrypt the data
$encrypteddata
and then use something like
echo "The secret password is:" .?encrypteddata = ©Âûr”q‘ûn¬.¢¿Î܇òAÉ\0
Should I just use base_64 encode?