}
/**
- * Determines given password's strength: 0 = bad, 100 = best. This method is
+ * Determines given password's strength: 0 = worst, 100 = best. This method is
* based on
* http://stackoverflow.com/questions/1614811/how-do-i-measure-the-strength-of-a-password
* <p>
// Init score
double score = 0.0f;
- //password length
+ // Password length
score += password.length() * calculateEntropyFactor(password) / 100;
- //password has 3 numbers
+ // Password has 3 numbers
if (ifRegExFoundInString("(.*[0-9].*[0-9].*[0-9].*)+", password)) { //NOI18N
score += 5;
}
- //password has 2 symbols
+ // Password has 2 symbols
if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password)) { //NOI18N
score += 5;
}
- //password has Upper and Lower chars
+ // Password has Upper and Lower chars
if (ifRegExFoundInString("(.*[a-z].*[A-Z])|([A-Z].*[a-z].*)+", password)) { //NOI18N
score += 10;
}
- //password has number and chars
+ // Password has number and chars
if (ifRegExFoundInString("(.*[a-zA-Z].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N
score += 15;
}
- //password has number and symbol
+ // Password has number and symbol
if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N
score += 15;
}
- //password has char and symbol
+ // Password has char and symbol
if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[a-zA-Z].*)+", password)) { //NOI18N
score += 15;
}
- //password is just numbers or chars
+ // Password is just numbers or chars
if (ifRegExFoundInString("^[a-zA-Z]+$", password) || ifRegExFoundInString("^[0-9]+$", password)) { //NOI18N
score -= 10;
}