note 13427 added to function.rand.php
| From: | php at authenticwalk dot com | Date: | Sat, 16 Jun 2001 01:26:03 +0000 |
| Subject: | note 13427 added to function.rand.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14280@lists.php.net to get a copy of this message | ||
Thanks for your comments guys, I often find a lot of good thoughts on these pages. Thought it was
time to add one of my own. Here is a random password generator that makes real word passwords that
are easier to remember, you might want to add another 50 words or so making it harder to hack.
<?
// Random Password generator
$words = array ('cat', 'dog', 'hat', 'happy',
'laugh', 'fun', 'mouse', 'puppy', 'joy',
'grace', 'peace', 'faith', 'hope', 'love',
'kind', 'good', 'gentle', 'life');
$maxrnd = count($words) - 1; // Count how many there are in case add or take some out
srand ( (double) microtime()*10000000); //set rand()
$rand_num = rand(0,$maxrnd); //random number
$password = $words[$rand_num];
$rand_num = rand(0,99); //random number
$password .= $rand_num;
$rand_num = rand(0,$maxrnd); //random number
$password .= $words[$rand_num];
echo $password;
?>
http://www.php.net/manual/en/function.rand.php