zoukankan
html css js c++ java
生成随机密码函数
两个产生随机密码函数:
函数一:
function
randomPassword(
$passwordLength
=
8
)
{
$str
=
"
abcefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
"
;
if
(
$passwordLength
>
strlen
(
$str
))
$passwordLength
=
strlen
(
$str
);
if
(
$passwordLength
<
8
)
$passwordLength
=
8
;
$start
=
mt_rand
(
1
,
(
strlen
(
$str
)
-
$passwordLength
));
$string
=
str_shuffle
(
$str
);
$password
=
substr
(
$string
,
$start
,
$passwordLength
);
return
(
$password
);
}
函数二:
function
randomPassword(
$passwordLength
=
8
)
{
//
密码字符串
define
(
"
PASS_STRING
"
,
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
"
);
if
(
$passwordLength
<
8
)
$passwordLength
=
8
;
for
(
$i
=
1
;
$i
<=
$passwordLength
;
$i
++
)
{
$randomPosition
=
rand
(
0
,
strlen
(PASS_STRING)
-
1
);
$password
.=
substr
(PASS_STRING
,
$randomPosition
,
1
);
}
return
$password
;
}
查看全文
相关阅读:
Java速成笔记
C语言学习笔记
形式语义05 Semantics
密码学04 PRG&PRF
形式语义04 Types
密码学03 Computational
形式语义03 Lambda
密码学02 Perfect
形式语义01 Intro
密码学01 Intro
原文地址:https://www.cnblogs.com/ywkpl/p/1054077.html
最新文章
手把手教你webpack、react和node.js环境配置(下篇)
手把手教你webpack、react和node.js环境配置(上篇)
探究CSS中的包裹性
前端学习资源整理
JS中的onclick事件
我的2016
css中的那些布局
一道闭包题引发的思考
JS传值和传引用
JS排序算法
热门文章
luogu_P1447 [NOI2010]能量采集
luogu_P2679 子串
luogu_P4568 [JLOI2011]飞行路线
luogu_P1314 聪明的质监员
luogu_P5367 【模板】康托展开
luogu_P5020 货币系统
luogu_P1063 能量项链
luogu_P3203 [HNOI2010]弹飞绵羊
luogu_ P1941 飞扬的小鸟
scheme学习笔记
Copyright © 2011-2022 走看看