Created
November 10, 2010 00:14
-
-
Save adrianpike/670099 to your computer and use it in GitHub Desktop.
Pronounceable password generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function makeRandomPassword() { | |
| $vowels = "aeiou"; | |
| $consonants = "bcdfghjklmnpqrstvwxyz"; | |
| $numbers = "0123456789"; | |
| srand((double)microtime()*1000000); | |
| $i = 0; // # of chars; | |
| $j=0; // Position. 0=consonant, 1 & 2 = vowels | |
| while ($i <= 6) { | |
| if ($j==0) { | |
| $num = rand() % 21; | |
| $tmp = substr($consonants, $num, 1); | |
| } else { | |
| $num = rand() % 5; | |
| $tmp = substr($vowels, $num, 1); | |
| } | |
| $pass = $pass . $tmp; | |
| $i++; | |
| $j++; if ($j>2) { | |
| $j=0; | |
| } } | |
| $num = rand() % 10; | |
| $tmp = substr($numbers, $num, 1); | |
| $pass = $pass . $tmp; | |
| $num = rand() % 10; | |
| $tmp = substr($numbers, $num, 1); | |
| $pass = $pass . $tmp; | |
| return $pass; | |
| } | |
| echo makeRandomPassword(); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment