最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 生成随机密码函数
时间:2022-06-24 16:05:53 编辑:袖梨 来源:一聚教程网
名称:random_password()
#
#作者:克里斯亨特,杰里米阿什克拉夫特
#
#日期:1999年5月,2000年10月
#
#用途:返回一个作为密码使用随机单词。元音和辅音
#是交替给一个(希望)pronouncable,因此
#难忘的结果。
#
#用法:$ my_new_password = random_password();
#
#(c)1999年克里斯亨特。授予权限是自由包括此脚本
#您的程序。提供这个头是原封不动。
#
#2000年10月 - 茉莉酸 - Perl代码移植到PHP
function random_password() {
$maxlen = 6; # Default to 6
# Build tables of vowels & consonants. Single vowels are repeated so that
# resultant words are not dominated by dipthongs$vowel = array ("a","e", "i", "o", "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 = "";srand((double) microtime()*1000000);
$vowelnext = (int)rand(0,1); # Initialise to 0 or 1 (ie true or false)do {
if ($vowelnext) {
$password = $password.$vowel[rand(0,sizeof($vowel))];
} else {
$password = $password.$consonant[rand(0,sizeof($consonant))];
}$vowelnext = !$vowelnext; # Swap letter type for the next one
} while (strlen($password) <$maxlen);
return $password;
}
相关文章
- 埃隆·马斯克背书推动比特币逼近11万美元 07-08
- Dreamweaver怎么裁剪图片? dw编辑图片的技巧 07-08
- CS2裂变天地s1赛程表一览 07-08
- 斗罗大陆猎魂世界武魂融合技如何发动 07-08
- 必须拿住:迈克尔·赛勒发布比特币牛市图表 07-08
- 大侠立志传爱猫失踪任务完成指南 07-08