note 26574 modified in ref.mcrypt by derick
| From: | derick@php.net | Date: | Fri, 25 Apr 2003 19:11:39 +0000 |
| Subject: | note 26574 modified in ref.mcrypt by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47107@lists.php.net to get a copy of this message | ||
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).
--was--
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).
I have to say 1 self-explanatory line into 5 lines (one of which is pointless) to do the same thing
doesn't seem like progress!
http://www.php.net/manual/en/ref.mcrypt.php