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
>
查看全文
相关阅读:
JAVA实现的异步redisclient
权限表设计
操作系统之存储管理(续)
leetcode第一刷_Jump Game
linux之stat函数解析
重温微积分 —— 偏微分与链式法则
重温微积分 —— 偏微分与链式法则
所谓敏感(数字的敏感)
所谓敏感(数字的敏感)
推理集 —— 特殊的工具
原文地址:https://www.cnblogs.com/xiang/p/400164.html
最新文章
华为的JAVA面试题及答案(部分)
STL之Map的运用
并查集类的c++封装,比較union_find algorithm四种实现方法之间的性能区别
关于开源的RTP——jrtplib的使用
Linux守护进程的编程实现
关于SetCapture() 和 ReleaseCapture()的使用方法
Atitit. .net c# web 跟clientwinform 的ui控件结构比較
eclipse+webservice开发实例
codechef Little Elephant and Permutations题解
iOS Mac系统下Ruby环境安装
热门文章
LDAPserver的安装
平衡二叉树
学习OpenCV第0天
Handler和HandlerThread
Unity手游之路<七>角色控制器
python爬虫之採集——360联想词W2版本号
C/C++开发工具大比拼【转】
架构师之路(39)---IoC框架
关于 ioctl 的 FIONREAD 參数
Sublime Text 3 史上最性感的编辑器
Copyright © 2011-2022 走看看