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
>
查看全文
相关阅读:
VIM配置
guanyuzhuguosha
会议室同步时钟布置
npm ERR! missing script: dev npm ERR! A complete log of this run can be found in: npm ERR!
Xmind2021安装激活破解
SpringCloudAlibaba 中文文档
flex布局 滚动条失效
Luogu P3397 地毯
Luogu P4343 自动刷题机
Luogu P1902 刺杀大使
原文地址:https://www.cnblogs.com/xiang/p/400164.html
最新文章
题解 CF1227G 【Not Same】
this.$refs与created()的坑 在created中获取不到ref
vue + element plus 实现可编辑table
reactive ref toref torefs 的区别和使用
vue 面试题
关于elemen-plus/elemen-ui Carousel走马灯图片不显示的问题
快速删除vue项目中的node_module文件夹
python获取上周的起始日期
python获取某一年的所有节假日
python 随机生成基金数据
热门文章
python 画基金涨幅图
git 超前1个版本, 落后2个版本的解决办法。
中欧基金涨幅预测
中欧医疗健康基金预测
分析中欧医疗健康基金涨幅
Android Studio编译
Mac 电脑输入java命令提示找不到的问题
Charles将证书设置为根证书
人工智能 之 KellyCoinflip
HE ZK 滚粗记
Copyright © 2011-2022 走看看