You are viewing a single comment's thread. Return to all comments →
public static int minimumNumber(int n, String password) { // Return the minimum number of characters to make the password strong int count=0; Pattern p1 = Pattern.compile("[0-9]"); Pattern p2 = Pattern.compile("[a-z]"); Pattern p3 = Pattern.compile("[A-Z]"); Pattern p4 = Pattern.compile("[!@#$%^&*()\\-+]"); Matcher m1 = p1.matcher(password); Matcher m2 = p2.matcher(password); Matcher m3 = p3.matcher(password); Matcher m4 = p4.matcher(password);
if(!m1.find()){ count++; System.out.println("xx"); } if(!m2.find()){ count++; } if(!m3.find()){ count++; } if(!m4.find()){ count++; }
int size=password.length(); if(size>=6){ return count; }else{ if(size+count>=6){ return count; }else{ return (6-(size+count))+count; } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →
Java
if(!m1.find()){ count++; System.out.println("xx"); } if(!m2.find()){ count++; } if(!m3.find()){ count++; } if(!m4.find()){ count++;
}