note 75106 rejected from function.mcrypt-encrypt by tularis
| From: | tularis@php.net | Date: | Sat, 12 May 2007 20:48:51 +0000 |
| Subject: | note 75106 rejected from function.mcrypt-encrypt by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126465@lists.php.net to get a copy of this message | ||
Note Submitter: Rebootedc at gmail dot com
----
For some odd reason this code:
<?
function encrypt($text) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crptext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $CONF[crypt_key], $text, MCRYPT_MODE_ECB, $iv);
return (base64_encode($crptext));
}
?>
[Where $CONF[crypt_key] is a key I used in the configuration values.]
Worked flawlessly in my 4.3.11 PHP version.
But now I recently upgraded to 4.4.7 (mantaining the same php.ini) and I had problems when passing a
crypted code through URL, and I noticed that I had to 'urlencode' the result of the
crypting function for it to work again. It always failed when any 'strange' character
(like +) appeared in the code.
So now under 4.4.7, this is the crypting function that works for me:
<?
function encrypt($text) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crptext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $CONF[crypt_key], $text, MCRYPT_MODE_ECB, $iv);
return urlencode(base64_encode($crptext));
}
?>
I wonder why that different behaviour between 4.3.x and 4.4.x...