密码限制8-20位,要求大小写字母、数字、特殊符号至少包含三种。代码如下:
public static Boolean checkPassWordIsStrong(String passWord) {
if (passWord == null)
return false;
if (passWord.length() < 8 || passWord.length() > 20)
return false;
int count = 0;
if (passWord.matches(".*[A-Z].*"))
count ++;
if (passWord.matches(".*[a-z].*"))
count ++;
if (passWord.matches(".*[0-9].*"))
count ++;
if (passWord.matches(".*\p{Punct}.*"))
count ++;
return count >= 3;
}
最后
以上就是无限果汁最近收集整理的关于JAVA密码校验的全部内容,更多相关JAVA密码校验内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复