note 26574 deleted from ref.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:28:44 +0000 |
| Subject: | note 26574 deleted from ref.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174878@lists.php.net to get a copy of this message | ||
Note Submitter: paul at xmill dot com
----
The statement that use of the 'generic' functions is 'recommended' in 2.4+
should probably be 'required'. Having like many others struggled with a "mcrypt
module initialization failed" error even when phpinfo() showed mcrypt installed and all its
algorithms loaded, I found that:
$key = mcrypt_ecb (MCRYPT_3DES, $magic, $input, MCRYPT_ENCRYPT);
fails, but
$td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init ($td, $magic, $iv);
$key = mcrypt_generic ($td, $input);
mcrypt_generic_end ($td);
works fine. You can't leave out the creation of the IV to the right length, even though ECB
doesn't use it (happily, because I want it repeatable).