Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. import cpu.Crypt;
  2.  
  3. import java.io.UnsupportedEncodingException;
  4. import java.util.Random;
  5. import java.util.concurrent.atomic.AtomicLong;
  6.  
  7. /**
  8. * @author anon
  9. */
  10. public class TripGen {
  11.  
  12. public static final Random r = new Random();
  13.  
  14. public static final char[] CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrtsuvwxyz1234567890.".toCharArray();
  15.  
  16. public static AtomicLong al = new AtomicLong(0);
  17.  
  18. public static void main(String[] args) throws UnsupportedEncodingException {
  19. if (args.length == 0) {
  20. System.out.println("You're retarded.");
  21. return;
  22. }
  23. String search = args[0];
  24. final long start = System.currentTimeMillis();
  25. final int threadCount = Runtime.getRuntime().availableProcessors() / 2;
  26.  
  27. System.out.println("Thread Count:" + threadCount);
  28.  
  29. //I really should use a threadpool here...
  30. for (int i = 0; i < threadCount; i++) {
  31. new Thread(() -> {
  32. for (; ; ) {
  33. char[] password = randChars(r.nextInt(5) + 3);
  34. char[] salt = salt(password);
  35. long l = al.addAndGet(1);
  36. String trip = Crypt.crypt(salt, password);
  37. if (trip.contains(search)) { // case sensitive, using startsWith and endsWith is faster as well
  38.  
  39. long rt = (System.currentTimeMillis() - start) / 1000;
  40. long ps = l / (rt == 0 ? 1 : rt);
  41. System.out.println(new String(password) + ":" + trip + " Count:" + l + " TPS:" + ps + " Runtime:" + rt);
  42. }
  43. }
  44. }).start();
  45. }
  46.  
  47. }
  48.  
  49. private static char[] salt(char[] password) {
  50. char[] salt = {password[1], password[2], '.', 'H'};
  51. /*
  52. // if password is fed in by a human we'd want to do this shit.... but we generate valid chars anyways, so why bother?
  53. for (int i = 0; i < b.length; i++) {
  54. if (b[i] < '.' || b[i] > 'z') {
  55. b[i] = '.';
  56. }
  57.  
  58. for (int j = 0; j < search.length; j++) {
  59. if (b[i] == search[j]) {
  60. b[i] = replace[j];
  61. }
  62. }
  63. }
  64. */
  65. return salt;
  66. }
  67.  
  68. private static char[] randChars(int len) {
  69. char[] res = new char[len];
  70. for (int i = 0; i < len; i++) {
  71. res[i] = CHARS[r.nextInt(CHARS.length)];
  72. }
  73. return res;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement