note 27756 deleted from function.rand by sniper

From: Date: Tue, 23 Sep 2003 22:32:54 +0000
Subject: note 27756 deleted from function.rand by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57000@lists.php.net to get a copy of this message
Note Submitter: entis@poczta.fm ---- correct RandomPassword function : function RandomPassword( $passwordLength ) { $password = ""; for ($index = 1; $index <= $passwordLength; $index++) { // Pick random number between 1 and 61 $randomNumber = rand(1, 61); // Select random character based on mapping. if ($randomNumber < 11) $password .= Chr($randomNumber + 48 - 1); // [ 1,10] => [0,9] else if ($randomNumber < 36) $password .= Chr($randomNumber + 65 - 10); // [11,36] => [A,Z] else $password .= Chr($randomNumber + 97 - 36); // [37,62] => [a,z] } return $password; }

« previous php.notes (#57000) next »