mercredi 14 septembre 2016

I am trying to create a password checker in java with a length of 8 characters or more, one upper case, one lower case, and a symbol.

I am really new to all this so let me use that as a preface in case this looks really really bad. The details are in the title but it is basically equal to or 8 characters in length, one upper case, one lower case, and a symbol that is neither a letter or number

       Scanner s = new Scanner(System.in); 
       String outputString = "";
       String lowerCaseAlphabet = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
       String upperCaseAlphabet = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
       String numbers.equals ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
       String symbols = ("!", "@", "#", "$", "%", "^", "&", "*", "(",  ")", "-", "=", "+", "\", ", "{", "[", ";", ":", "/", "?", ">", ".", "<", ","); 


       System.out.print("Please enter a password: ");
       outputString = s.nextLine();

       System.out.println("Entered Password:\t" + outputString);
       if (outputString.length() > 8)
         if (outputString.contains(upperCaseAlphabet)) 
            if (outputString.contains(lowerCaseAlphabet))
               if (outputString.contains(numbers))
                  if (outputString.contains(symbols))
         System.out.println("Verdict:\t\t Valid"); 
       else {
       System.out.println("Vredict:\t\t Invalid");
       }   
    }
}

Aucun commentaire:

Enregistrer un commentaire