zoukankan
html css js c++ java
检验密码强度的JS类
<
script type
=
"
text/javascript
"
>
var
PasswordStrength
=
{
Level : [
"
高,实在是高
"
,
"
还行啦
"
,
"
靠,这样也行
"
],
LevelValue : [
30
,
20
,
0
],
//
强度值
Factor : [
1
,
2
,
5
],
//
字符加数,分别为字母,数字,其它
KindFactor : [
0
,
0
,
10
,
20
],
//
密码含几种组成的加数
Regex : [
/
[a
-
zA
-
Z]
/
g,
/
\d
/
g,
/
[
^
a
-
zA
-
Z0
-
9
]
/
g]
//
字符正则数字正则其它正则
}
PasswordStrength.StrengthValue
=
function
(pwd)
{
var
strengthValue
=
0
;
var
ComposedKind
=
0
;
for
(
var
i
=
0
; i
<
this
.Regex.length;i
++
)
{
var
chars
=
pwd.match(
this
.Regex[i]);
if
(chars
!=
null
)
{
strengthValue
+=
chars.length
*
this
.Factor[i];
ComposedKind
++
;
}
}
strengthValue
+=
this
.KindFactor[ComposedKind];
return
strengthValue;
}
PasswordStrength.StrengthLevel
=
function
(pwd)
{
var
value
=
this
.StrengthValue(pwd);
for
(
var
i
=
0
; i
<
this
.LevelValue.length ; i
++
)
{
if
(value
>=
this
.LevelValue[i] )
return
this
.Level[i];
}
}
alert(PasswordStrength.StrengthLevel(
"
23
"
));
alert(PasswordStrength.StrengthLevel(
"
abcd123
"
));
alert(PasswordStrength.StrengthLevel(
"
abcd!%23
"
));
</
script
>
查看全文
相关阅读:
3.4.2内核下的I2C驱动
AS3批量替换文件
文件访问权限
Windows快捷键
整数与字符串之间的转换函数
Windows获取文件大小
Windows内核对象
ASCII字符集
IP协议
获取真正的进程/线程句柄
原文地址:https://www.cnblogs.com/xiang/p/400164.html
最新文章
nginx反向代理
LNMP应用
NGINX常用模块(二)
nginx常用模块(一)
nginx入门
HTTP
Ansible-playbook
Ansible部署rsync、nfs及sersync
TP5单文件、多文件上传
TP5环境变量设置
热门文章
TP5不安装composer使用验证码
uevent
tslib编译使用方法
RTC驱动程序
NOR FLASH驱动程序
NAND FLASH驱动程序
input子系统
LCD驱动程序
I2C驱动程序
Android系统开发
Copyright © 2011-2022 走看看