Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6. import java.util.zip.CRC32;
  7.  
  8. public class Main {
  9.  
  10. public static void main(String[] args) throws IOException {
  11. CRC32 crc32 = new CRC32();
  12. String guessHash = "BA02B6E1";
  13. File infile = new File("C:\\Users\\User\\Desktop\\pass.txt");
  14. FileInputStream in = new FileInputStream(infile);
  15. Scanner scanner = new Scanner(in);
  16. ArrayList <String> words = new ArrayList<String>();
  17. while(scanner.hasNext()){
  18. words.add(scanner.nextLine());
  19. }
  20. System.out.println("There are " + words.size() + " in dictionary file");
  21. for(int i = 0; i < words.size(); i++) {
  22. String word1 = null;
  23. crc32.reset();
  24. word1 = words.get(i);
  25. crc32.update(word1.getBytes());
  26. long hash1 = crc32.getValue();
  27. String hash2 = Long.toHexString(hash1).toUpperCase();
  28. if (hash2.equals(guessHash)){
  29. System.out.println(word1);
  30. break;
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement