Geekpedia Programming Tutorials






Random Password Using PHP

A function that generates strong passwords by mixing uppercase and lowercase characters with numbers.

On Tuesday, June 10th 2008 at 03:02 PM
By Andrei Pociu (View Profile)
****-   (Rated 4 with 2 votes)
Contextual Ads
More PHP Resources
Advertisement
  1. function RandPass($PassLength)
  2. {
  3.         $PassStr = "";
  4.         for ($i = 0; $i <= $PassLength; $i++)
  5.         {
  6.                 $CurrChar='';
  7.                 switch (mt_rand(1,3))
  8.                 {
  9.                         case 1:
  10.                                 $CurrChar = chr(mt_rand(48,57));
  11.                                 break;
  12.                         case 2:
  13.                                 $CurrChar = chr(mt_rand(65,90));
  14.                                 break;
  15.                         case 3:
  16.                                 $CurrChar = chr(mt_rand(97,122));
  17.                                
  18.                 }
  19.                 $PassStr .= $chr;
  20.         }       
  21.         return $PassStr;
  22. }
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by Prashant on Tuesday, June 17th 2008 at 02:15 AM

Nice code...


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs PHP Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons