Browse Source

Pwcheckerclass

master
drddro 1 year ago
parent
commit
b228366702
2 changed files with 16 additions and 6 deletions
  1. 10
    6
      src/PasswordChecker.java
  2. 6
    0
      src/Validation.java

+ 10
- 6
src/PasswordChecker.java View File

public class PasswordChecker {
public class PasswordChecker implements Validation{


private final static int pwMinLength = 6;
private final int pwMinLength;


public static boolean pwLength(String password){
public PasswordChecker(int minPwSize){
pwMinLength = minPwSize;
}

public boolean pwLength(String password){
return password.length() >= pwMinLength; return password.length() >= pwMinLength;
} }


public static boolean pwContainsNum(String password){
public boolean pwContainsNum(String password){
for (int i = 0; i < password.length(); i++) { for (int i = 0; i < password.length(); i++) {
if(Character.isDigit(password.charAt(i))){ if(Character.isDigit(password.charAt(i))){
return true; return true;
return false; return false;
} }


private static boolean pwContainsSpecialHelper(char c){
private boolean pwContainsSpecialHelper(char c){
return(!(Character.isDigit(c)|| Character.isLetter(c))); return(!(Character.isDigit(c)|| Character.isLetter(c)));
} }


public static boolean pwContainsSpecial(String password){
public boolean pwContainsSpecial(String password){
for (int i = 0; i < password.length(); i++) { for (int i = 0; i < password.length(); i++) {
if(pwContainsSpecialHelper(password.charAt(i))){ if(pwContainsSpecialHelper(password.charAt(i))){
return true; return true;

+ 6
- 0
src/Validation.java View File

public interface Validation {

boolean pwLength(String pw);
boolean pwContainsNum(String pw);
boolean pwContainsSpecial(String pw);
}

Loading…
Cancel
Save