note 113601 deleted from function.crypt by peehaa

From: Date: Mon, 04 Nov 2013 09:08:46 +0000
Subject: note 113601 deleted from function.crypt by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197422@lists.php.net to get a copy of this message
Note Submitter: Mitchell ---- Another way of generating salt with use, but also independently of mcrypt extension: <?php function getSalt($saltLength = 22) { if (extension_loaded('mcrypt')) { $salt = mcrypt_create_iv($saltLength, MCRYPT_DEV_URANDOM); } else { $salt = ''; for ($i=0; $i<$saltLength; $i++) { $salt.= chr(mt_rand(0, 255)); } } return substr(strtr(base64_encode($salt),'+','.'),0,$saltLength); } ?>

« previous php.notes (#197422) next »