RE: [PHP] Random Password Making.

From: Date: Fri, 28 Mar 2003 12:16:22 +0000
Subject: RE: [PHP] Random Password Making.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141425@lists.php.net to get a copy of this message
try this function randpassword () { $length = 6; srand((double)microtime()*1000000); $string = ''; while(strlen($string) != $length) { $type = rand(1,2); if ($letterammount = 4) {$type = 1;} if ($numammount = 2) {$type = 2;} if($type == 1) { $string = $string . chr(rand(48,57)); // numbers $numammount = ($numammount + 1); } if($type == 2) { $lettertype = rand(1,2); if($lettertype == 1) {$string = $string . chr(rand(65,90));} // uppercase letters if($lettertype == 2) {$string = $string . chr(rand(97,122));} // lowercase letters $letterammount = ($letterammount + 1); } } return($string); } hope that helps Regards Mark Cubitt > -----Original Message----- > From: Philip J. Newman [mailto:newmanpj@philipnz.com] > Sent: 28 March 2003 11:33 > To: php-general@lists.php.net > Subject: [PHP] Random Password Making. > > > Whats the best way to make a random password with 4 letters and 2 numbers? > > > ------ > Philip J. Newman. > Head Developer > info@philipnz.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > ****************************************************************** > ************ > This email has been virus checked by the Eclipse Internet > MAILsafe service > ****************************************************************** > ************ > www: http://www.eclipse.net.uk/ email: > eclipse@eclipse.net.uk > ****************************************************************** > ************ > >

« previous php.general (#141425) next »