source: trunk/www.guidonia.net/wp/wp-admin/js/password-strength-meter.dev.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 719 bytes
Line 
1// Password strength meter
2function passwordStrength(password,username) {
3 var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, symbolSize = 0, natLog, score;
4
5 //password < 4
6 if (password.length < 4 ) { return shortPass };
7
8 //password == username
9 if (password.toLowerCase()==username.toLowerCase()) return badPass;
10
11 if (password.match(/[0-9]/)) symbolSize +=10;
12 if (password.match(/[a-z]/)) symbolSize +=26;
13 if (password.match(/[A-Z]/)) symbolSize +=26;
14 if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
15
16 natLog = Math.log( Math.pow(symbolSize,password.length) );
17 score = natLog / Math.LN2;
18 if (score < 40 ) return badPass
19 if (score < 56 ) return goodPass
20 return strongPass;
21}
Note: See TracBrowser for help on using the repository browser.