runxinzhi.com
首页
百度搜索
生成随机密码函数
两个产生随机密码函数:
函数一:
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
;
}
相关阅读:
23种设计模式
Java实现动态代理的两种方式
jQuery easyui combobox级联及内容联想
使用Spring MVC统一异常处理
springmvc下使用kaptcha做验证码
Hadoop及spark介绍
jQuery easyui 之 expend row
Http 1.1协议
公钥、私钥、CA认证、数字签名、U盾
SOA架构介绍
原文地址:https://www.cnblogs.com/ywkpl/p/1054077.html
最新文章
【tmux环境配置】在centos6.4上配置tmux
【vim环境配置】在centos6.4上配置vim的一些零碎记录
【vim环境配置】详细实录
为什么要搞vim
【APUE】Chapter9 Process Relationships
【APUE】Chapter8 Process Control
【APUE】Chapter7 Process Environment
【APUE】Chapter12 Thread Control
【APUE】Chapter11 Threads
如何自己编译apue.3e中代码 & 学习写makefile
热门文章
mapreduce v1.0学习笔记
Hadoop1.0之集群搭建
ZooKeeper之初识
N天学习一个Linux命令之dmesg
N天学习一个Linux命令之top
N天学习一个Linux命令之free
N天学习一个linux命令之diff
N天学习一个linux命令之ssh-keygen
N天学习一个linux命令之ping
N天学习一个linux命令之ssh
Copyright © 2020-2023
润新知