Skip to content

Instantly share code, notes, and snippets.

@adrianpike
Created November 10, 2010 00:14
Show Gist options
  • Save adrianpike/670099 to your computer and use it in GitHub Desktop.
Save adrianpike/670099 to your computer and use it in GitHub Desktop.
Pronounceable password generator
<?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