Quite often you need to generate passwords for user authentication systems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php
function make_password($length){
$vowels = 'aeiouy';
$consonants = 'bdghjlmnpqrstvwxz';
$password = '';
$alt = time() % 2;
srand(time());
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % 17)];
$alt = 0;
} else {
$password .= $vowels[(rand() % 6)];
$alt = 1;
}
}
return $password;
}
echo make_password(8);
?>
|
Years ago I found this function to create pseudo-english passwords when I needed something simple for a website I was working on. I've since simplified it, but it is essentialy the same. This works by inserting a vowel in between every consonant.
Tags: security
weak passwords. to my opinion passwords containing only lower case vowels and consonants are weak passwords. generated passwords should be a mixture between lower/uppercase alphabetic chars and numbers.
maybe this function should be changed. but this is just my personal opinion
Strong Passwords. This function could generate strong passwords. All one needs to do is modify the $vowels and $consonants variables to include both upper and lower case letters. One could even put numbers in either of these variables.
I like this function simple and concise.
Stronger Password Generation. $vowels = 'aeiouyAEIOUY' $consonants = 'bdghjlmnpqrstvwxzBDGHJLMNPQRSTVWXZ' $specials = '1234567890@#$%^$vowels = 'aeiouyAEIOUY' $consonants = 'bdghjlmnpqrstvwxzBDGHJLMNPQRSTVWXZ' $specials = '1234567890@#$%^
How about.
</pre>
Sorry about that. The posting went haywire - I think ActiveState have a problem with submitting comments. - Alan