note 34873 deleted from function.rand by aidan

From: Date: Sat, 10 Jul 2004 02:37:43 +0000
Subject: note 34873 deleted from function.rand by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72973@lists.php.net to get a copy of this message
Note Submitter: arend@auton.nl ---- And yet another variation on the random password generation. It is a variation on the algorithm from 'admin at gwdn dot com' and performs exactly the same function, though it ought to be even faster since it doesn't have to use regular expression matching. function randomPassword($len = 8) { $pass = ''; $lchar = 0; $char = 0; for($i = 0; $i < $len; $i++) { while($char == $lchar) { $char = rand(48, 109); if($char > 57) $char += 7; if($char > 90) $char += 6; } $pass .= chr($char); $lchar = $char; } return $pass; } Arend jr.

« previous php.notes (#72973) next »