|
Recently I was required to write a password strength meter in Filemaker,here I am sharing the logic behind evaluating password strength, which will give you a clear idea for writing one in your own working platform.As we know, the instantaneous visual feedback provides the user a means to improve the strength of their passwords, with a hard focus on breaking the typical bad habits of faulty password formulation. Here are the password strength factors and weightings which I have taken in account here for this function. |
| Password length: level 0 (3 point): less than 4 characters level 1 (6 points): between 5 and 7 characters level 2 (12 points): between 8 and 15 characters
level 3 (18 points): 16 or more characters letters: level 0 (0 points): no letters exist level 1 (1 points): at least one lower case letter exist level 2 (5 points): at least one upper case letter exist numbers: level 0 (0 points): no numbers exist level 1 (5 points): at least one number exist level 1 (5 points): at least three numbers exist special characters: level 0 (0 points): no special characters exist level 1 (5 points): at least one special character exist level 2 (5 points):at least two special characters exist combinatons: level 0 (2 points): both upper and lower case exist level 1 (2 points): both letters and numbers exist level 2 (2 points): letters, numbers, and special characters exist |
function checkPassword(passwd)
{
var intScore = 0
var intPasswdLen = passwd.length
// Password Leagth
if (intPasswdLen4 && intPasswdLen7 && intPasswdLen15) // check length 16 or more
{
intScore = (intScore+18)
}
// VERIFIED LETTERS
if (passwd.match(/[a-z]/)) // verified at least one lower case letter exist
{
intScore = (intScore+1)
}
if (passwd.match(/[A-Z]/)) // verified at least one upper case letter
{
intScore = (intScore+5)
}
// VERIFIED NUMBERS
if (passwd.match(/\d+/)) // verified at least one number
{
intScore = (intScore+5)
}
if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) // verified at least three numbers
{
intScore = (intScore+5)
}
// VERIFIED SPECIAL CHAR
if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) // verified at least one special character
intScore = (intScore+5)
}
// verified at least two special characters
if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
{
intScore = (intScore+5)
}
// COMBOS
if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) // verified both upper and lower case exist
{
intScore = (intScore+2)
}
if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // verified both letters and numbers
{
intScore = (intScore+2)
}
// verified letters, numbers, and special characters
if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
{
intScore = (intScore+2)
}
//Return Score
return (intScore)
}
//Set status of password if required in above code by if-else conditional statement
Score 15 and Score 24 and Score 34 and Score =45 : strStatus = "strong"