note 13427 deleted from function.rand by jimw

From: Date: Tue, 18 Dec 2001 19:33:13 +0000
Subject: note 13427 deleted from function.rand by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23158@lists.php.net to get a copy of this message
Generates a password using a random word (from a list you provide) and appends a random number. Not ideal for uber-security but the idea works. Also ouputs rAndOm CasE : $words = array ('bread', 'apple', 'mississippi', 'globe', 'kind', 'good', 'life'); function genPassword ($words, $min_num = 101, $max_num = 99999, $sep = NULL) { global $seed; $word = ''; $size = sizeof($words) - 1; if (!empty($seed)) { mt_srand ((double) microtime()*10000000); $seed = TRUE; } $raw_word = $words[mt_rand(0,$size)]; for($a=0; $a <= strlen($raw_word); $a++) { $case_func = mt_rand(0,1) ? 'strtoupper' : 'strtolower'; $word .= $case_func($raw_word{$a}); } return $word . $sep . mt_rand($min_num,$max_num); }

« previous php.notes (#23158) next »