Re: random letters and numbers

From: Date: Wed, 25 Apr 2001 03:17:38 +0000
Subject: Re: random letters and numbers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50224@lists.php.net to get a copy of this message
Sup, I made this and have been using it for about 6 months without problem. mt_rand() is 4 times faster than normal rand(), remember to use mt_srand() to seed. The 8 in the while controls how long the $password will be... $count = 0; mt_srand( (double) microtime() * 1000000); while( $count < 8 ) { $randval = mt_rand(48 , 122); $timeout++; // currently allows 0-9 and a-z (lowercase), add 65-90 for uppercase if(($randval > 47 && $randval < 58) || ($randval > 96 && $randval < 123)) { $password .= chr($randval); $count++; } } SL. ----- Original Message ----- From: "Randy Johnson" <programmer@jennybug.com> Cc: "Php-General" <php-general@lists.php.net> Sent: Tuesday, April 24, 2001 12:10 AM Subject: [PHP] random letters and numbers > Is there a way to generate a random set of characters ranging from 8 to 12 > characters and numbers where it is crucial that the letters and numbers are > truly random because I need to create temporary files for people to download > information. > > Any links/suggestions would be greatly appreciated > > Thanks > > Randy > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#50224) next »