Simple PHP Password generator
by Manigandan[ Edit ] 2011-05-31 15:30:53
function generatePassword($length, $strength)
{
$vowels = 'aeiou';
$consonants = 'bdghjmnpqrstvz';
if ($strength==1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength==2) {
$vowels .= "AEUY";
}
if ($strength==4) {
$consonants .= '23456789';
}
if ($strength==
{
$consonants .= '@#$%';
}
$password = '';
$timestamp= time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($timestamp == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$timestamp = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$timestamp = 1;
}
}
return $password;
}