note 1321 modified in crypt by ronabop

From: Date: Sat, 09 Sep 2000 02:37:32 +0000
Subject: note 1321 modified in crypt by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-4578@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 http://www.php.net/manual/function.crypt.php

« previous php.notes (#4578) next »