2010.10.22密码校验(小写,大写,数字)

时间:2013-11-11 10:44:28
【文件属性】:

文件名称:2010.10.22密码校验(小写,大写,数字)

文件大小:1KB

文件格式:JAVA

更新时间:2013-11-11 10:44:28

java 密码 校验

private boolean checkPassword(String password) { int numberCount = 0; int upperCaseCount = 0; int lowerCaseCount = 0; int numberIndex = 0; int upperCaseIndex = 0; int lowerCaseIndex = 0; for (int i = 0; i < password.length(); i++) { char temp = password.charAt(i); if (temp >= 48 && temp <= 57) { numberIndex = i; numberCount++; }else if(temp >= 65 && temp <= 90){ upperCaseIndex = i; upperCaseCount++; }else if(temp >= 97 && temp <= 122){ lowerCaseIndex = i; lowerCaseCount++; } } if (numberCount == 0 || (numberCount == 1 && (numberIndex == 0 || numberIndex == password.length()-1 ))) { return false; } if (upperCaseCount == 0 || (upperCaseCount == 1 && (upperCaseIndex == 0 || upperCaseIndex == password.length()-1 ))) { return false; } if (lowerCaseCount == 0 || (lowerCaseCount == 1 && (lowerCaseIndex == 0 || lowerCaseIndex == password.length()-1 ))) { return false; } return true; }


网友评论