【发布时间】:2016-01-24 12:26:31
【问题描述】:
我需要生成带有条件的随机密码:
- 除了“l1o0” 之外的所有字符都是允许的
- 长度为 8 到 12 个字符
我尝试过的代码:
function generateRandomPassword() {
//Initialize the random password
$password = '';
//Initialize a random desired length
$desired_length = rand(8, 12);
for($length = 0; $length < $desired_length; $length++) {
//Append a random ASCII character (including symbols)
$password .= chr(rand(32, 126));
}
return $password;
}
如何避免这 4 个字符 => "l1o0" ?
原因:
- 这 4 个字符有时会使用户感到困惑。
谢谢!
【问题讨论】:
标签: php security random passwords