encryption - Error with my brute force password generator(Java) -


This is an assignment for the square, basically creates a method that can "guess" the password and then I can send it to another class. D-crypt file is a difficult part with me.

  import sussex.edu.cryptography; Public square final {public static zero major (string [] args) {// decryptter (); Cryptography crypto = new cryptography (); String Encrypted = "SourceFile_encrypted.txt"; String decrypted = "SourceFile_decrypted.txt"; String password = new string (); crypto.setPassword (password); If (crypto.isPasswordValid ()) {System.out.println ("found password:" + password); Crypto.decryptFile (encrypted, decrypted); } Else {// continue trying ...}} public static string decryptor () {char arrays [] = new characters [5]; Cryptography crypto = new cryptography (); String password = new string (); For (four c = 'a'; c and lt; = 'z'; c ++) {array [0] = c; (Four c1 = 'a'; c1 and lt; = 'z'; c1 ++) {array [1] = c1; For (four c2 = 'a', c2 and lt; = 'z'; c2 ++) {array [2] = c2; (4 C3 = 'A'; C3 and LT; = 'Z'; C3 ++) {array [3] = C3; (4 C4 = 'A'; C4 and LT; = 'Z'; C4 ++) {array [4] = C4; String s = new string (array); Password = s; Println (password); crypto.setPassword (password); If (crypto.isPasswordValid ()) {break; }}}}}} Return password; }}   

It repeats all possible passwords, and goes before the actual password, (OHH) and nothing does when I manually crypto.setPassword first ( Password); It works just fine. When I enter it, it looks like the crypto .setupword ("OLLEH"); But if I manually enter "OLLEH" in crypto.setPassword (password); This does not work inside the nested for the loop, so my glitch is there, I can not see it.

Maybe you have PasswordValid () method <= P>

compare strings In comparison to the equivalent ().

This can be understood from why this comparison is true against "OLLEH", but false when with the same value of a string, but new .

Password = s; by password = s.intern ();

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -