您的位置:首页 > 其它

测测你的密码需要多久被破译!密码强弱度的正则判断

2011-09-14 23:06 316 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: