Advertisement
oscarholmedo

PHP Random password generator

Apr 15th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. function GeneratePassword($length=8, $strength=0){
  2.     $vowels = 'aeuy';
  3.     $consonants = 'bcdghjmnpqrstvw';
  4.     if($strength >= 1) $consonants .= 'BCDGHJLMNPQRSTVW';
  5.     if($strength >= 2) $vowels .= 'AEUY';
  6.     if($strength >= 3) $consonants .= '12345';
  7.     if($strength >= 4) $consonants .= '67890';
  8.     if($strength >= 5) $vowels .= '@#$%';
  9.  
  10.     $password = '';
  11.     $alt = time() % 2;
  12.     for($i = 0; $i < $length; $i++){
  13.         if($alt == 1){
  14.             $password .= $consonants[(rand() % strlen($consonants))];
  15.             $alt = 0;
  16.         }else{
  17.             $password .= $vowels[(rand() % strlen($vowels))];
  18.             $alt = 1;
  19.         }
  20.     }
  21.     return $password;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement