博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

java 判断密码强度

Posted on 2013-11-13 12:51  TimeFight  阅读(1928)  评论(0)    收藏  举报
public static String checkPassword(String passwordStr) {
		String regexZ = "\\d*";
		String regexS = "[a-zA-Z]+";
		String regexT = "\\W+$";
		String regexZT = "\\D*";
		String regexST = "[\\d\\W]*";
		String regexZS = "\\w*";
		String regexZST = "[\\w\\W]*";

		if (passwordStr.matches(regexZ)) {
			return "弱";
		}
		if (passwordStr.matches(regexS)) {
			return "弱";
		}
		if (passwordStr.matches(regexT)) {
			return "弱";
		}
		if (passwordStr.matches(regexZT)) {
			return "中";
		}
		if (passwordStr.matches(regexST)) {
			return "中";
		}
		if (passwordStr.matches(regexZS)) {
			return "中";
		}
		if (passwordStr.matches(regexZST)) {
			return "强";
		}
		return passwordStr;

	}