help with making a password checker in java

Posted by Cheesegraterr on Stack Overflow See other posts from Stack Overflow or by Cheesegraterr
Published on 2010-04-03T02:39:42Z Indexed on 2010/04/03 2:43 UTC
Read the original article Hit count: 404

Filed under:
|
|
|
|

Hello, I am trying to make a program in Java that checks for three specific inputs. It has to be 1. At least 7 characters. 2. Contain both upper and lower case alphabetic characters. 3. Contain at least 1 digit. So far I have been able to make it check if there is 7 characters, but I am having trouble with the last two. What should I put in my loop as an if statement to check for digits and make it upper and lower case. Any help would be greatly appreciated. Here is what I have so far.

import java.awt.*;
import java.io.*;
import java.util.StringTokenizer;

public class passCheck
{


    private static String getStrSys ()
    {
        String myInput = null;          //Store the String that is read in from the command line

        BufferedReader mySystem;        //Buffer to store the input

        mySystem = new BufferedReader (new InputStreamReader (System.in)); //creates a connection to system input
        try
        {
            myInput = mySystem.readLine (); //reads in data from the console
            myInput = myInput.trim ();
        }
        catch (IOException e)  //check
        {
            System.out.println ("IOException: " + e);
            return "";
        }
        return myInput; //return the integer to the main program
    }


    //****************************************
    //main instructions go here
    //****************************************

    static public void main (String[] args)
    {

        String pass;         //the words the user inputs
        String temp = "";            //holds temp info

        int stringLength;          //length of string
        boolean goodPass = false;


        System.out.print ("Please enter a password: ");  //ask for words

        pass = getStrSys ();                              //get words from system
        temp = pass.toLowerCase ();
        stringLength = pass.length ();             //find length of eveyrthing



        while (goodPass == false)

            {
                if (stringLength < 7)
                {
                    System.out.println ("Your password must consist of at least 7 characters");
                    System.out.print ("Please enter a password: ");  //ask for words
                    pass = getStrSys ();
                    stringLength = pass.length ();
                    goodPass = false;
                }
                else if (something to check for digits)
                {







                }

            }

© Stack Overflow or respective owner

Related posts about java

Related posts about password