Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: How to make a very simple Password Strength indicator?

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation How to make a very simple Password Strength indicator?

    Hi there! I am developing a number of Data Structures in Bluej. Iv created a nice little arraylist program, and want to add a password generator to this program. People are already prestored within the arraylist, and contain attributes such as ID, name, password, etc. I can search a persons name within the list and then view their ID, password, and encrypted password. I want to add a field which will show password strength, bare in mind the password is already stored within the program and will not be entered via the user.

    I understand that this could be done via a regular expression, or using some count method where certain goals/sets of characters increase the count which determine strength. I understand the very basic concepts of java and programming, but really don't know how to put this idea into code or something.. Can someone help? Or direct me to a good source that is most relevant to my situation?

    Thank You!


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: How to make a very simple Password Strength indicator?

    What would be your definition of a "simple" indicator?
    What are the requirements for a good password that you want to implement?

    If you know what requirements you want you only have to go through them one by one. Break it down into small steps, right them down on a piece of paper or somewhere else, as plain text, and then try to translate your plain text into java code.

    If you have more specific questions about implementation details or you need help with a specific error, then post again and we will try to help you.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a very simple Password Strength indicator?

    Well, simple as in;

    I start with a count that is = 1 (Very low strength password)

    Other password strength levels are:

    2= low strength password
    3= medium strength password
    4= high strength password
    5= very high strength password

    more than 5 character password and the count goes up by 1
    if both uppercase and lowercase letters are used then count goes up by 1
    if special characters (for example: £) are used then count goes up by 1
    and if numbers are used then count goes up by 1

    Strength would be indicated by the list of attributes of a person; so name, id, password, encrypted password, and then the status of the password strength.

    I dont know how to search for specific characters such as this or to code the program to analyse the string like this. I have the idea through my basic knowledge of programming but i am unable to properly code this.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to make a very simple Password Strength indicator?

    I dont know how to search for specific characters
    Look at the Character class. It has lots of methods for checking characters.
    The String class has a method for getting characters from a String.

    See the API doc for those classes.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a very simple Password Strength indicator?

    Heres my code so far. It says cannot convert int to boolean though? I understand data types and why there is conflict within my code but do not understand how to resolve this, can you help?

    I am getting an error: incompatible types: int cannot be converted to boolean.

    I understand data types and understand the conflict within the code but do not understand how i can resolve this.

    private int checkPasswordStrength(String passw) 
        {
                    int strengthCount=0;
            String[] partialRegexChecks = { ".*[a-z]+.*", // lower
                                            ".*[A-Z]+.*", // upper
                                            ".*[\\d]+.*", // digits
                                            ".*[@#$%]+.*" // symbols
            };
                        if (passw.matches(partialRegexChecks[0])) {
                        strengthCount+=1;
                }
                        if (passw.matches(partialRegexChecks[1])) {
                        strengthCount+=1;
                }
                        if (passw.matches(partialRegexChecks[2])) {
                        strengthCount+=1;
                }
                        if (passw.matches(partialRegexChecks[3])) {
                        strengthCount+=1;
                }
     
                if (strengthCount=1) {
                    strengthCount=Weak;
                }
     
                if (strengthCount=2) {
                    strengthCount=Meduim;
                }
     
                if (strengthCount=3) {
                    strengthCount=High;
                }
     
                if (strengthCount=1) {
                    strengthCount=VeryHigh;
                }
            return strengthCount;
        }
    Last edited by blobby404; June 18th, 2014 at 06:07 PM. Reason: General Cleanup + Additional Details

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to make a very simple Password Strength indicator?

    Threads merged.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.

    If you are getting errors, copy the full text of the error message and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a very simple Password Strength indicator?

    Done.

    I am getting an error: incompatible types: int cannot be converted to boolean.

    I understand data types and understand the conflict within the code but do not understand how i can resolve this.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to make a very simple Password Strength indicator?

    int cannot be converted to boolean.
    The statement where that is happening has been left off the error message.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a very simple Password Strength indicator?

     
     if (strengthCount=1) {
                    strengthCount=Weak;
                }

    This is where the error begins.

    Error: incompatible types: int cannot be converted to boolean.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to make a very simple Password Strength indicator?

    The expression in the () is an assignment statement (=), not a comparison (==).
    An assignment statement returns an int value, a comparison returns a boolean.

    The if requires a boolean. Change the = to ==
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Re: How to make a very simple Password Strength indicator?

    Thank you, iv adapted my code accordingly but receive a new error.

     
     if (strengthCount==1) {
                    strengthCount=Weak;
                }

    Error: cannot find symbol - variable Weak

    I assume that i am doing to what i am trying to achieve is wrong.

    IF the strengthcount is equal to 1 then i want the strengthcount to output the password as "weak". The password comes from a premade method in the program which will output the user in a list, with their information including ID, name, password, and password strength. However i want the password strength to display as "weak" or "strong" or "meduim" depending on their password of course. I dont understand how i can convert the count number to a word that can be outputted in the program.

    Any suggestions are greatly appreciated. If you could modify my example so that it could work in the way that i described then that would be great.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to make a very simple Password Strength indicator?

    cannot find symbol - variable Weak
    The compiler can not find a definition for the variable Weak.

    Do you want to work with Strings and use the value of the int variable: strengthCount to assign a String like "Weak" to a String variable?
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Jun 2014
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to make a very simple Password Strength indicator?

    Yes

Similar Threads

  1. Password Strength Meter
    By Dr.Kernel in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 4th, 2011, 09:17 AM
  2. Replies: 2
    Last Post: October 11th, 2011, 09:41 AM
  3. Simple beginner's password guessing program
    By edishuman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 12th, 2011, 03:59 PM
  4. Add MS Office communicator presence indicator into JSP.
    By priteshg23 in forum Java Native Interface
    Replies: 0
    Last Post: November 9th, 2010, 02:53 AM
  5. Password Strength Checker
    By uthuth in forum Object Oriented Programming
    Replies: 1
    Last Post: February 6th, 2010, 04:09 PM

Tags for this Thread