raw
mp-wp_genesis           1 // Password strength meter
mp-wp_genesis 2
mp-wp_genesis 3 function passwordStrength(password,username) {
mp-wp_genesis 4 var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4;
mp-wp_genesis 5
mp-wp_genesis 6 //password < 4
mp-wp_genesis 7 if (password.length < 4 ) { return shortPass };
mp-wp_genesis 8
mp-wp_genesis 9 //password == username
mp-wp_genesis 10 if (password.toLowerCase()==username.toLowerCase()) return badPass;
mp-wp_genesis 11
mp-wp_genesis 12 var symbolSize = 0;
mp-wp_genesis 13 if (password.match(/[0-9]/)) symbolSize +=10;
mp-wp_genesis 14 if (password.match(/[a-z]/)) symbolSize +=26;
mp-wp_genesis 15 if (password.match(/[A-Z]/)) symbolSize +=26;
mp-wp_genesis 16 if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
mp-wp_genesis 17
mp-wp_genesis 18 var natLog = Math.log( Math.pow(symbolSize,password.length) );
mp-wp_genesis 19 var score = natLog / Math.LN2;
mp-wp_genesis 20 if (score < 40 ) return badPass
mp-wp_genesis 21 if (score < 56 ) return goodPass
mp-wp_genesis 22 return strongPass;
mp-wp_genesis 23 }