JAVA密码校验

来源:互联网 发布:windows phone8.1更新 编辑:程序博客网 时间:2024/05/01 22:56

密码限制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;    }


0 0
原创粉丝点击