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
>
查看全文
相关阅读:
【转】staruml用户手册目录【中文翻译版】
[转]“菜”鸟理解.NET Framework(CLI,CLS,CTS,CLR,FCL,BCL)
[转]程序员面试题精选100题(51)顺时针打印矩阵
[转] 程序员面试题精选100题(35)找出两个链表的第一个公共结点
[转] 深入探索.NET框架内部了解CLR如何创建运行时对象
海量数据处理的几种方法总结 .
分析函数总结
PLSQL实现排序(冒泡、选择、快速)
oracle 分析函数2
创建表分区的总结
原文地址:https://www.cnblogs.com/xiang/p/400164.html
最新文章
没有App_Code,如何使用ASP.NET控件?
HTML在线编辑器控件
HtmlTextWriter类的学习
没有App_Code,如何使用ASP.NET控件?
CSS中的滑动门技术
10106 Product
644 Immediate Decodability
120 Stacks of Flapjacks
465 Overflow
644 Immediate Decodability(AC)
热门文章
10115 Automatic Editing
PKU 1088 滑雪
UVA 10494 If We Were a Child Again
UVA 10494 If We Were a Child Again(高精度除法和取余)
424 Integer Inquiry
[转] 寻找二叉树中两个节点的最近的公共祖先
Loads the specified manifest resource from this assembly
100道算法题总结
数据结构(树)
[转] 程序员面试题精选100题(16)-O(logn)求Fibonacci数列
Copyright © 2011-2022 走看看