Results 1 to 2 of 2
  1. #1
    starky is offline Member
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Default Password Strength Checker

    it had no syntax error but plsease tell me if there would be any other error or if i would receive a wrong result

    import java.util.*;
    class tester
    {
    public static void test()
    {
    Scanner input=new Scanner(System.in);
    int size= 0;
    System.out.println("Enter your password:");
    String enter=input.next();
    size = enter.length();
    //puttinng input into an array
    char[] b = new char[size];
    enter.getChars(0,size,b,0);
    int c, u=0, l=0, d=0, m=0, t=0, cu=0, cl=0, s=0, sd=0 , only=0;
    c = size * 4;
    for(char o:b){
    //checking UpperCases
    if(Character.isUpperCase(o)){
    u = u + 2;
    }
    //checking LowerCases
    if(Character.isLowerCase(o)){
    l = l + 2;
    }
    //checking Digits
    if(Character.isDigit(o)){
    d= d + 2;
    }
    //checking number of digits between first and last char
    for(int i=1;i<size;i++){
    if(Character.isDigit(b[i])){
    m = m+2;
    }
    }
    //checking number of Character used more than one time
    for(int k=1;k<size;k++){
    if((int)o == (int)b[k]){
    t = t + 2;
    }
    }
    //testing if any of the character are in alphabetic order(uppercase)
    int p =(int) o;
    if(p >=65 && p<=90){
    for(int k=1;k<size;k++){
    int r = (int) b[k];
    if(r == p-1){
    s = s + 2;
    }
    }
    }
    //testing if any of the character are in alphabetic order(lowercase)
    if(p >=97 && p<=122){
    for(int k=1;k<size;k++){
    int r = (int) b[k];
    if(r == p-1){
    s = s + 2;
    }
    }
    }
    //testing if any of the character are in order (digits)
    if(p >=48 && p<=57){
    for(int k=1;k<size;k++){
    int r = (int) b[k];
    if(r == p-1){
    sd = sd + 2;
    }
    }
    }
    for(int k=1;k<size;k++){
    //testing number of consecutive uppercase letters
    if(Character.isUpperCase(o)){
    if(Character.isUpperCase(b[k])){
    cu = cu + 2;

    }

    }
    //testing number of consecutive lowercase letters
    if(Character.isLowerCase(o)){
    if(Character.isLowerCase(b[k])){
    cl = cl + 2;

    }

    }
    }
    //testing if there are only letters
    int a =0;
    if(Character.isLetter(o)){
    a = a+1;
    if(a == size){
    only = size;
    }
    }
    //testing if there are only digits
    int dig =0;
    if(Character.isDigit(o)){
    dig = dig+1;
    if(dig == size){
    only = size;
    }
    }
    }
    int points = c+u+l+d+m;
    int penalities =t+cu+cl+s+sd+only;
    int score = points - penalities;
    //Final Step: Testing the score
    if(score<=29){
    System.out.println("weak");
    }
    if(score<=59 && score>=30){
    System.out.println("moderate");
    }
    if(score<=79 && score>=60){
    System.out.println("strong");
    }
    if(score>=80){
    System.out.println("very strong");
    }
    }

    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Password Strength Checker

    When posting code, please use the code tags to preserve formatting.

    What does this code do? Have you run through it with a bunch of example input?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Password Checker
    By lily_ruiz_06 in forum New To Java
    Replies: 4
    Last Post: 02-17-2013, 11:47 PM
  2. how to check password for 3 times enterd wrong password
    By sk.mahaboobbhasha@gmail.c in forum New To Java
    Replies: 2
    Last Post: 11-14-2008, 08:53 PM
  3. How to check password of a jsp/html with the password of Database(mysql) #1
    By sk.mahaboobbhasha@gmail.c in forum Java Servlet
    Replies: 2
    Last Post: 11-14-2008, 02:11 PM
  4. WiFi signal strength
    By islamfunny in forum CLDC and MIDP
    Replies: 1
    Last Post: 10-02-2008, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •