`
wangxuliangboy
  • 浏览: 208366 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

密码强度检测

 
阅读更多


    public static int charMode(char ch) {
        if (ch >= 48 && ch <= 57) // 数字
        return 1;
        if (ch >= 65 && ch <= 90) // 大写字母
        return 2;
        if (ch >= 97 && ch <= 122) // 小写
        return 4;
        else return 8; // 特殊字符
    }

    /**
     * @param str
     * @return
     */
    public static int checkPassword(String str) {
        int mode = 0;
        char ch;
        for (int i = 0; i < str.length(); i++) {
            ch = str.charAt(i);
            mode = mode | charMode(ch);
        }
        return mode;
    }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics