okay, so I have been working on a java brute force program that will read passwords from a txt file and stop when it matches a password stored in a String variable. For, some reason my code goes on reading the whole txt file and does not stop even if it matches the correct password.
Here's my code.
PasswordCracker2.java
import java.io.*;
public class PasswordCracker2 {
public static void main(String[] args) throws IOException {
String password = "busch@123";
File f = new File("wordlist.txt");
BufferedReader b = new BufferedReader(new FileReader(f));
String readLine = "";
System.out.println("[+] Trying Passwords from wordlist \n");
String guess_password;
while ((guess_password = b.readLine()) != null) {
System.out.println("[+] Password Attempt: " + guess_password);
if(guess_password == password) {
System.out.println("[+] Password Cracked: " + guess_password);
}
}
}
}