http://howsecureismypassword.net/
public static int parsePassword(String password) {
int result = 0;
Pattern ps = Pattern
.compile("[a-zA-Z0-9_\\,\\.\\-\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\+]{6,16}");
Pattern lower = Pattern.compile("[a-z]");
Matcher mlower = lower.matcher(password);
Pattern upper = Pattern.compile("[A-Z]");
Matcher mupper = upper.matcher(password);
Pattern special = Pattern
.compile("[_\\,\\.\\-\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\+]");
Matcher mspecial = special.matcher(password);
if (ps.matcher(password).matches()) {
if (mspecial.find()) {
result = 3;
} else if (mupper.find()) {
result = 2;
} else if (mlower.find()) {
result = 1;
}
}
return result;
}
本文介绍了一个用于检测密码强度的Java算法。该算法通过正则表达式检查密码是否包含大小写字母及特殊字符,并据此评估密码的安全等级。

4326

被折叠的 条评论
为什么被折叠?



