Problem with mcrypt_encrypt and mcrypt_decrypt.
| From: | francesco at automationsoft dot biz | Date: | Wed, 28 Jan 2004 14:29:41 +0000 |
| Subject: | Problem with mcrypt_encrypt and mcrypt_decrypt. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176042@lists.php.net to get a copy of this message | ||
Hi all,
i'm trying to crypt and decrypt password with the code below but i get many warnings
Warning: mcrypt_get_iv_size(): Module initialization failed in
/web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 36
Warning: mcrypt_create_iv(): Can not create an IV with size 0 or smaller in
/web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 37
Warning: mcrypt_decrypt(): Module initialization failed in
/web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 38
and i don't understand why, any help is appreciated.
Code is below.
This code is in a script
//Start crypt
$iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC);
$iv=mcrypt_create_iv($iv_size,MCRYPT_RAND);
$key=genera();// genera() function for rand number
$emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv);
$emailcifrata=$key.$emailcifrata;
// End crypt
This code is in another script that isn't the same script of previous
//Start decrypt
$emailcifrata=fgets($fp);
$lunghezza_str=strlen($emailcifrata);
$emailcifrata=substr($emailcifrata,10);
$key=substr($emailcifrata,0,($lunghezza_str-10));
$iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC);
$iv=mcrypt_create_iv($iv_size,MCRYPT_RAND);
$email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv);
// End decrypt
Thanks in advance.