Results 1 to 4 of 4
  1. #1
    swedishfished is offline Member
    Join Date
    Sep 2012
    Posts
    24
    Rep Power
    0

    Default Checking a Password's Safety

    Dear Guys and Gals!
    So, for a project, I am trying to see how long it takes my computer to brute force hack my password. Currently, it is not working! I think it might be that variable i is not becoming 0. Try it out. Also, if you see anything else that I can improve on in my code, please tell me!
    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class herp extends JFrame {
    	private JTextField password;
    	private JButton insert;
    	public herp(){
    		super("TitleBar");
    		password = new JTextField(20);
    		insert = new JButton("CrackIt");
    		add(password);
    		add(insert);
    		HandlerClass handler = new HandlerClass();
    		insert.addActionListener(handler);
    		setLayout(new FlowLayout());	
    	}
    	private class HandlerClass implements ActionListener{
    		public void actionPerformed(ActionEvent event){
    		Object obj1 = new Object();
    		obj1 = password.getText();
    		String obj2= new String();
    		obj2 = obj1.toString();
    		crackIt(obj2);
    	}
    	}
    	public void crackIt(String origPass)
    	{
    		char[] passCrack;
    	for(int i = 1; i!=0; i++)
    		{
    		int x=i;
    		passCrack = new char[i];
    		while(x>0)
    			{
    		for(int i2 = 65; i2<91; i2++)
    				{
    			passCrack[x-1] = (char)i2;
    				}
    		String finalString = new String(passCrack);
    		if(finalString == origPass){
    			JOptionPane.showMessageDialog(null, String.format("The pw was %s", finalString));
    		i = 0;
    		
    		}
    		x--;
    			}
    		}
    	}
    }

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,390
    Rep Power
    5

    Default Re: Checking a Password's Safety

    I have not tried to follow your algorithm so I don't know if it will work or not. However, your string comparison of finalString to origPass will never be true. You should use finalString.equals(origPass) to test string equality. And as a general practice you should not be calling CPU intensive methods from
    within any event handler. This will make your implementation non-responsive to other events.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    swedishfished is offline Member
    Join Date
    Sep 2012
    Posts
    24
    Rep Power
    0

    Default Re: Checking a Password's Safety

    Ohhh ok thanks! I'm pretty sure the algorithm works, and that I have mostly been derping around with lots of errors. How should I do this without calling CPU intensive methods in an event handler?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Checking a Password's Safety

    Quote Originally Posted by swedishfished View Post
    How should I do this without calling CPU intensive methods in an event handler?
    Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 05-08-2013, 07:19 PM
  2. Thread safety?
    By werner291 in forum New To Java
    Replies: 0
    Last Post: 11-12-2011, 10:12 AM
  3. 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, 07:53 PM
  4. how to check password for 3 times enterd wrong password
    By sk.mahaboobbhasha@gmail.c in forum Java Servlet
    Replies: 0
    Last Post: 11-14-2008, 01:22 PM
  5. 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, 01:11 PM

Posting Permissions

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