Created
March 7, 2014 09:37
-
-
Save jermenkoo/9408482 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final char[] SPECIAL = "$!+\-#?_%&/".toCharArray(); | |
private static final char[] NUMBER = "0123456789".toCharArray(); | |
public static boolean checkValidation(String password) | |
{ | |
int points = 0; | |
String lowerPass = password.toLowerCase(); | |
String upperPass = password.toUpperCase(); | |
if(!password.equals(lowerPass) && !password.equals(upperPass)) | |
{ | |
// if contains upper or lower letter | |
points++; | |
} | |
if(contains(password, SPECIAL)) | |
{ | |
// if it contains special character | |
points++; | |
} | |
if(contains(password, NUMBER)) | |
{ | |
// if it contains Number | |
points++; | |
} | |
return points >= 2; | |
} | |
public static boolean contains(String pwd, char[] value) | |
{ | |
int i = 0; | |
boolean success = false; | |
while(i < value.length && !success) | |
{ | |
if(pwd.indexOf(""+value[i]) != -1) | |
{ | |
success = true; | |
} | |
i++; | |
} | |
return success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment