php判断密码强度函数

其实就是一些策略正则,写好了就留下来以后用。

 

 1 print_r(getPasswordStrength('s1212adsddfASD;\'g;\'gh.h,h..;'));
 2 
 3 
 4 function getPasswordStrength($password)
 5 {
 6 $score = 0;
 7 if(preg_match("/[0-9]+/",$password))
 8 {
 9 $score ++;
10 }
11 if(preg_match("/[0-9]{3,}/",$password))
12 {
13 $score ++;
14 }
15 if(preg_match("/[a-z]+/",$password))
16 {
17 $score ++;
18 }
19 if(preg_match("/[a-z]{3,}/",$password))
20 {
21 $score ++;
22 }
23 if(preg_match("/[A-Z]+/",$password))
24 {
25 $score ++;
26 }
27 if(preg_match("/[A-Z]{3,}/",$password))
28 {
29 $score ++;
30 }
31 if(preg_match("/[_\W]+/",$password))
32 {
33 $score += 2;
34 }
35 if(preg_match("/[_\W]{3,}/",$password))
36 {
37 $score ++ ;
38 }
39 if(strlen($password) >= 10)
40 {
41 $score ++;
42 }
43 return $score;
44 }

 

转载于:https://www.cnblogs.com/mrxigua/p/3196371.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值