1 // Password strength meter
2 function passwordStrength(password,username) {
3 var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, symbolSize = 0, natLog, score;
6 if (password.length < 4 ) { return shortPass };
9 if (password.toLowerCase()==username.toLowerCase()) return badPass;
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;
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