note 44621 deleted from ref.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:27:31 +0000 |
| Subject: | note 44621 deleted from ref.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174872@lists.php.net to get a copy of this message | ||
Note Submitter: Wilmo
----
Changing the function as such seems to greatly help.
<?php
function encrypt($encrypt) {
global $key;
srand((double) microtime() * 1000000); //for sake of MCRYPT_RAND
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, MCRYPT_MODE_ECB, $iv);
$encode = base64_encode($passcrypt);
return $encode;
}
?>
by adding:
<?php
srand((double) microtime() * 1000000); //for sake of MCRYPT_RAND
?>
which I guess seeds the encryption routine differently everytime.
Thanks to robert at peakepro dot com sourced from
http://www.php.net/manual/en/function.mcrypt-create-iv.php
Cheers,
Wil