note 75106 added to function.mcrypt-encrypt

From: Date: Sat, 12 May 2007 15:22:39 +0000
Subject: note 75106 added to function.mcrypt-encrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-126461@lists.php.net to get a copy of this message
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... ---- Server IP: 130.206.1.5 Probable Submitter: 80.35.246.214 ---- Manual Page -- http://www.php.net/manual/en/function.mcrypt-encrypt.php Edit -- https://master.php.net/note/edit/75106 Del: integrated -- https://master.php.net/note/delete/75106/integrated Del: useless -- https://master.php.net/note/delete/75106/useless Del: bad code -- https://master.php.net/note/delete/75106/bad+code Del: spam -- https://master.php.net/note/delete/75106/spam Del: non-english -- https://master.php.net/note/delete/75106/non-english Del: in docs -- https://master.php.net/note/delete/75106/in+docs Del: other reasons-- https://master.php.net/note/delete/75106 Reject -- https://master.php.net/note/reject/75106 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126461) next »