<?
// I don't remember where this code originally came from. I know that this
// was written in PERL by someone other than me.
function random_password($len = 6)
{
$vowel = array("a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "o", "o",
"o", "u", "u", "y", "ai", "au", "ay", "ea", "ee", "eu", "ia", "ie",
"io", "oa", "oi", "oo", "oy"
);
$consonant = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n",
"p", "qu", "r", "s", "t", "v", "w", "x", "z", "th", "st", "sh",
"ph", "ng", "nd"
);
$password = "";
mt_srand((double) microtime() * 10000);
$vowelnext = mt_rand(0,1); // Initialise to 0 or 1 (ie true or false)
while (strlen($password) < $len) {
if ($vowelnext) {
$password .= $vowel[rand(0, count($vowel)-1)];
} else {
$password .= $consonant[rand(0, count($consonant)-1)];
}
$vowelnext = !$vowelnext; // Swap letter type for the next one
}
return(substr($password, 0, $len));
}
$saltChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
$salt = $saltChars[mt_rand(0, strlen($saltChars)-1)] . $saltChars[mt_rand(0, strlen($saltChars)-1)];
$pass = random_password($len);
$cleartext = $pass;
$md5 = crypt($pass);
$des = crypt($pass, $salt);
?>