Mon Feb 28, 2011 11:24 am
public class passwordStrength {
private int checkPasswordStrength(String password) {
int strengthPercentage=0;
String[] partialRegexChecks = { ".*[a-z]+.*", // lower
".*[A-Z]+.*", // upper
".*[\\d]+.*", // digits
".*[@#$%]+.*" // symbols
};
if (password.matches(partialRegexChecks[0])) {
strengthPercentage+=25;
}
if (password.matches(partialRegexChecks[1])) {
strengthPercentage+=25;
}
if (password.matches(partialRegexChecks[2])) {
strengthPercentage+=25;
}
if (password.matches(partialRegexChecks[3])) {
strengthPercentage+=25;
}
return strengthPercentage;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.