Password Level

本文介绍了一个使用JavaScript实现的密码强度检测功能。通过分析密码组成,包括数字、大小写字母及特殊字符等,来评估密码强度并用不同颜色展示弱、中、强三个等级。
  1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <script type="text/javascript" src="http://knockoutjs.com/js/jquery-1.4.2.min.js"></script>
5 <script type="text/javascript" src="http://knockoutjs.com/js/jquery.tmpl.js"></script>
6 <script type="text/javascript" src="http://knockoutjs.com/js/knockout-1.2.1.js"></script>
7 </head>
8 <body>
9 <script type="text/javascript">
10 var Page = Page || {};
11 Page.Utility = Page.Utility || {};
12 Page.Utility.Registration = Page.Utility.Registration || {};
13
14 //获取密码强度
15 Page.Utility.Registration.getPasswordLevel =function (password) {
16 if (password ==null|| password =='')
17 return0;
18
19 if (password.length <=4)
20 return0; //密码太短
21
22 var Modes =0;
23 for (i =0; i < password.length; i++) {
24 Modes |= CharMode(password.charCodeAt(i));
25 }
26 return bitTotal(Modes);
27
28 //CharMode函数
29 function CharMode(iN) {
30 if (iN >=48&& iN <=57) //数字
31 return1;
32 if (iN >=65&& iN <=90) //大写字母
33 return2;
34 if (iN >=97&& iN <=122) //小写
35 return4;
36 else
37 return8; //特殊字符
38 }
39
40 //bitTotal函数
41 function bitTotal(num) {
42 modes =0;
43 for (i =0; i <4; i++) {
44 if (num &1) modes++;
45 num >>>=1;
46 }
47 return modes;
48 }
49 };
50
51 var viewModel = {
52 Password: ko.observable(""),
53 Ocolor: "#eeeeee"
54 };
55
56 viewModel.PasswordLevel = ko.dependentObservable(function () {
57 return Page.Utility.Registration.getPasswordLevel(this.Password());
58 }, viewModel);
59
60 viewModel.Lcolor = ko.dependentObservable(function () {
61 //根据密码强度判断第一个格显示的背景色
62 returnthis.PasswordLevel() ==0?this.Ocolor : (this.PasswordLevel() ==1?"#FF0000" : (this.PasswordLevel() ==2?"#FF9900" : "#33CC00"))
63 }, viewModel);
64
65 viewModel.Mcolor = ko.dependentObservable(function () {
66 //根据密码强度判断第二个格显示的背景色
67 returnthis.PasswordLevel() <2?this.Ocolor : (this.PasswordLevel() ==2?"#FF9900" : "#33CC00")
68 }, viewModel);
69
70 viewModel.Hcolor = ko.dependentObservable(function () {
71 //根据密码强度判断第二个格显示的背景色
72 returnthis.PasswordLevel() <3?this.Ocolor : "#33CC00"
73 }, viewModel);
74
75 $((function () {
76 ko.applyBindings(viewModel);
77 }));
78
79
80 </script>
81 <form name="form1" action="">
82 输入密码:<input type="text" size="10" data-bind="value:Password, valueUpdate: 'afterkeydown'">
83 <br>
84 密码强度:
85 <table width="217" border="1" cellspacing="0" cellpadding="1" bordercolor="#cccccc"
86 height="23" style='display: inline'>
87 <tr align="center" bgcolor="#eeeeee">
88 <td width="50" id="strength_L" data-bind="style: { backgroundColor: Lcolor }">
89
90 </td>
91 <td width="50" id="strength_M" data-bind="style: { backgroundColor: Mcolor }">
92
93 </td>
94 <td width="50" id="strength_H" data-bind="style: { backgroundColor: Hcolor }">
95
96 </td>
97 </tr>
98 </table>
99 </form>
100 </body>
101 </html>

转载于:https://www.cnblogs.com/changweihua/archive/2011/12/04/2276231.html

05-15
ersion 5.20, Release 1808P12 # sysname AYMYY_S5800_CORE # clock timezone Ningbo add 08:00:00 # password-control login-attempt 3 exceed lock-time 5 # super password level 3 cipher $c$3$mg0DLayA7IoGkbGRDM60vnNYOKcHfQAL2CsRx+c= # irf mac-address persistent timer irf auto-update enable undo irf link-delay # domain default enable system # port-security enable # loopback-detection enable loopback-detection multi-port-mode enable # mirroring-group 1 local # password-recovery enable # acl number 2000 rule 10 permit source 172.16.10.242 0 rule 20 permit source 172.16.10.108 0 rule 30 permit source 10.254.110.91 0 rule 40 permit source 10.254.80.166 0 rule 1000 deny # acl number 3000 rule 0 permit ip source 172.16.14.0 0.0.0.255 destination 172.16.10.7 0 rule 5 permit ip source 172.16.14.0 0.0.0.255 destination 172.16.10.100 0 rule 6 permit ip source 172.16.14.8 0 destination 172.16.10.0 0.0.0.255 rule 10 deny ip source 172.16.14.0 0.0.0.255 destination 172.16.10.0 0.0.0.255 rule 15 permit ip acl number 3001 rule 0 permit ip source 172.16.10.0 0.0.0.255 destination 172.16.14.8 0 rule 5 deny ip source 172.16.10.0 0.0.0.255 destination 172.16.14.0 0.0.0.255 rule 10 permit ip acl number 3101 rule 10 permit tcp source 172.16.10.108 0 destination 172.16.10.1 0 destination-port eq 3389 rule 15 deny tcp destination-port eq 3389 rule 20 permit ip # vlan 1 # vlan 2 to 6 # vlan 8 # vlan 10 # vlan 20 description internet # vlan 100 # vlan 300 # radius scheme system server-type extended primary authentication 127.0.0.1 1645 primary accounting 127.0.0.1 1646 user-name-format without-domain # domain system access-limit disable state active idle-cut disable self-service-url disable # user-group system group-attribute allow-guest # local-user adminDD password cipher $c$3$3qdA7xAZc3IE6qFaB13/YsI/jOV6mWGYbGFleemKaiUQ authorization-attribute level 3 service-type ssh local-user nbaym password cipher $c$3$o3L5zwZ6tiYYlwBcbF/wtxuOs24kd1z6Na7H5EPraA== authorization-attribute level 3 service-type ssh password-control aging 90 local-user nbaym_audit password cipher $c$3$5L+JRw2qI3ZP0zSMIgdeFeFPZyCVUPQznsUwzj+/J4rj2Q3Beg== authorization-attribute level 3 authorization-attribute user-role security-audit service-type ssh password-control aging 90 # cwmp undo cwmp enable # interface NULL0 # interface Vlan-interface1 ip address dhcp-alloc client-identifier mac Vlan-interface1 # interface Vlan-interface2 ip address 172.16.10.254 255.255.255.0 ip address 192.168.10.254 255.255.255.0 sub ip address 172.16.100.254 255.255.255.0 sub ip address 10.51.103.253 255.255.255.0 sub # interface Vlan-interface3 ip address 172.16.11.1 255.255.255.0 # interface Vlan-interface4 ip address 172.16.12.1 255.255.255.0 # interface Vlan-interface5 ip address 172.16.13.1 255.255.255.0 # interface Vlan-interface6 ip address 172.16.14.1 255.255.255.0 packet-filter 3000 inbound # interface Vlan-interface8 ip address 172.16.8.254 255.255.255.0 # interface Vlan-interface10 # interface Vlan-interface20 ip address 172.16.20.254 255.255.255.0 # interface Vlan-interface100 ip address 172.16.1.1 255.255.255.0 # interface Vlan-interface300 # interface GigabitEthernet1/0/24 port link-mode route ip address 192.168.100.254 255.255.255.0 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/1 port link-mode bridge port access vlan 20 loopback-detection enable mirroring-group 1 monitor-port # interface GigabitEthernet1/0/2 port link-mode bridge port access vlan 2 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/3 port link-mode bridge port access vlan 2 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/4 port link-mode bridge port access vlan 2 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/5 port link-mode bridge port access vlan 2 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/6 port link-mode bridge port access vlan 2 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/7 port link-mode bridge port link-type trunk port trunk permit vlan 1 to 6 loopback-detection enable mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/8 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/9 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/10 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/11 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/12 port link-mode bridge port access vlan 2 # interface GigabitEthernet1/0/13 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/14 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/15 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/16 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/17 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/18 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/19 port link-mode bridge port access vlan 8 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/20 port link-mode bridge port access vlan 8 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/21 port link-mode bridge port access vlan 2 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/22 port link-mode bridge port access vlan 100 mirroring-group 1 mirroring-port both # interface GigabitEthernet1/0/23 port link-mode bridge description con-msr3640-gongweiwang port access vlan 2 mirroring-group 1 mirroring-port both # interface Ten-GigabitEthernet1/0/25 port link-mode bridge # interface Ten-GigabitEthernet1/0/26 port link-mode bridge # interface Ten-GigabitEthernet1/0/27 port link-mode bridge # interface Ten-GigabitEthernet1/0/28 port link-mode bridge port access vlan 2 # ip route-static 0.0.0.0 0.0.0.0 172.16.20.253 ip route-static 10.17.0.0 255.255.0.0 10.51.103.254 ip route-static 10.51.0.0 255.255.0.0 10.51.103.254 ip route-static 10.51.103.0 255.255.255.0 10.51.103.254 ip route-static 10.87.0.0 255.255.0.0 172.16.1.2 ip route-static 10.247.0.0 255.255.0.0 172.16.1.2 ip route-static 10.249.0.0 255.255.0.0 172.16.1.2 ip route-static 10.254.0.0 255.255.0.0 10.51.103.254 ip route-static 59.255.0.0 255.255.0.0 10.51.103.254 ip route-static 59.255.152.8 255.255.255.255 10.51.103.254 ip route-static 170.1.2.160 255.255.255.252 172.16.1.2 ip route-static 172.16.10.0 255.255.255.0 172.16.11.254 ip route-static 172.16.10.0 255.255.255.0 59.255.152.6 ip route-static 172.16.10.244 255.255.255.254 59.255.152.6 ip route-static 172.16.11.1 255.255.255.255 172.16.10.1 ip route-static 172.16.11.1 255.255.255.255 172.16.10.206 ip route-static 172.31.117.0 255.255.255.0 10.51.103.254 ip route-static 192.168.0.0 255.255.0.0 10.51.103.254 ip route-static 192.168.1.0 255.255.255.0 172.16.8.253 ip route-static 192.168.213.0 255.255.255.0 172.16.10.206 ip route-static 215.20.132.0 255.255.255.0 172.16.1.2 ip route-static 215.20.132.20 255.255.255.252 172.16.1.2 ip route-static 215.249.99.0 255.255.255.0 172.16.1.2 # info-center loghost source Vlan-interface2 info-center loghost 172.16.10.107 # dhcp enable # ntp-service unicast-server 10.254.80.250 # ssh server enable ssh user nbaym service-type stelnet authentication-type password # load xml-configuration # load tr069-configuration # user-interface aux 0 authentication-mode password set authentication password cipher $c$3$MIeu7TJL/2Pts19+7pCWpwRuvZmVmwgmWzTk0E5opQ== user-interface vty 0 4 acl 2000 inbound authentication-mode scheme user privilege level 3 idle-timeout 15 0 protocol inbound ssh user-interface vty 5 15
最新发布
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值