Wordpress/wp-admin/js/password-strength-meter.js
Ryan Boren baaaa352ba Strip trailing whitespace
git-svn-id: https://develop.svn.wordpress.org/trunk@10150 602fd350-edb4-49c9-b593-d223f7449a82
2008-12-09 18:03:31 +00:00

23 lines
717 B
JavaScript

// Password strength meter
function passwordStrength(password,username) {
var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4;
//password < 4
if (password.length < 4 ) { return shortPass };
//password == username
if (password.toLowerCase()==username.toLowerCase()) return badPass;
var symbolSize = 0;
if (password.match(/[0-9]/)) symbolSize +=10;
if (password.match(/[a-z]/)) symbolSize +=26;
if (password.match(/[A-Z]/)) symbolSize +=26;
if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
var natLog = Math.log( Math.pow(symbolSize,password.length) );
var score = natLog / Math.LN2;
if (score < 40 ) return badPass
if (score < 56 ) return goodPass
return strongPass;
}