Javamex

Java discussion forum to accompany the Javamex web site.

I have 2 files , one zip file and one txt file. I want to find out the password of the zip file with the help of txt file.In txt file I have some words and one of them is the right password.The problem is here , when I put the right word at the first line of txt works but when i put it everywhere else it doesn't work.
I can't catch the entry once and keep it.
I suspect that the problem is here:

while ((entry = r.nextEntry())!= null && (line = br.readLine())!= null)

Here I saw you my programm.
So if anyone knows something , help!!!!!!!!!!!!!!!!
The password is "12345678" and is in txt file.

 import java.io.*;  
import com.javamex.arcmexer.*;

public class Decryption{
public static void main(String[] args) {
//String pw = "12345678";
String line = null;
//int recCount = 0;
int count = 0;
String x = null;
try {
FileInputStream f = new FileInputStream("C://ReadZip.zip");
ArchiveReader r = ArchiveReader.getReader(f);
ArchiveEntry entry ;
FileReader fr = new FileReader("C://test.txt");
BufferedReader br = new BufferedReader(fr);
while ((entry = r.nextEntry())!= null && (line = br.readLine())!= null) {
String filename = entry.getFilename();
System.out.println("What is the password of " + filename + "?");
if (entry.isProbablyCorrectPassword(line)){
System.out.println("Password found: " + line);
count++;
if (count==1)
x = "st" ;
else if (count==2)
x="nd";
else
x="th";
System.out.println("We found the password with the: " + count + x + " trial");
}else{
System.out.println("That password isn't the correct.Try again");
}
}
} catch (Exception e){
System.out.println("Exception raised!");
e.printStackTrace();
}
}
}

Views: 49

Replies are closed for this discussion.

© 2024   Created by Neil Coffey.   Powered by

Badges  |  Report an Issue  |  Terms of Service