note 1321 deleted from function.crypt by jimw

From: Date: Sat, 03 Nov 2001 18:15:40 +0000
Subject: note 1321 deleted from function.crypt by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20363@lists.php.net to get a copy of this message
If you want to make you own salt in php and don't trust the randomly generated one PHP provides I wrote a function that makes sure the salt is random enough.... function gensalt(){ function rannum(){ mt_srand((double)microtime()*1000000); $num = mt_rand(46,122); return $num; } function genchr(){ do{ $num = rannum(); } while ( ( $num > 57 && $num < 65 ) || ( $num > 90 && $num < 97 ) ); $char = chr($num); return $char; } $a = genchr(); $b = genchr(); $salt = "$a$b"; return $salt; } $result = gensalt(); echo $result"; Best Regards Lasse L. Johnsen

« previous php.notes (#20363) next »