function genpass_password in Generate Password 6
Same name and namespace in other branches
- 8 genpass.module \genpass_password()
- 7 genpass.module \genpass_password()
Generate a new password using genpass's internal password generation algorithm. Based on the original D6 user_password function (with more characters)
Return value
a fresh password according to the settings made in /admin/user/settings
See also
File
- ./
genpass.module, line 37
Code
function genpass_password() {
$pass = '';
$length = variable_get('genpass_length', 8);
$allowable_characters = variable_get('genpass_entropy', _genpass_default_entropy());
// Zero-based count of characters in the allowable list:
$len = strlen($allowable_characters) - 1;
// Loop the number of times specified by $length.
for ($i = 0; $i < $length; $i++) {
// Each iteration, pick a random character from the
// allowable string and append it to the password:
$pass .= $allowable_characters[mt_rand(0, $len)];
}
return $pass;
}