Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cpu.Crypt;
- import java.io.UnsupportedEncodingException;
- import java.util.Random;
- import java.util.concurrent.atomic.AtomicLong;
- /**
- * @author anon
- */
- public class TripGen {
- public static final Random r = new Random();
- public static final char[] CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrtsuvwxyz1234567890.".toCharArray();
- public static AtomicLong al = new AtomicLong(0);
- public static void main(String[] args) throws UnsupportedEncodingException {
- if (args.length == 0) {
- System.out.println("You're retarded.");
- return;
- }
- String search = args[0];
- final long start = System.currentTimeMillis();
- final int threadCount = Runtime.getRuntime().availableProcessors() / 2;
- System.out.println("Thread Count:" + threadCount);
- //I really should use a threadpool here...
- for (int i = 0; i < threadCount; i++) {
- new Thread(() -> {
- for (; ; ) {
- char[] password = randChars(r.nextInt(5) + 3);
- char[] salt = salt(password);
- long l = al.addAndGet(1);
- String trip = Crypt.crypt(salt, password);
- if (trip.contains(search)) { // case sensitive, using startsWith and endsWith is faster as well
- long rt = (System.currentTimeMillis() - start) / 1000;
- long ps = l / (rt == 0 ? 1 : rt);
- System.out.println(new String(password) + ":" + trip + " Count:" + l + " TPS:" + ps + " Runtime:" + rt);
- }
- }
- }).start();
- }
- }
- private static char[] salt(char[] password) {
- char[] salt = {password[1], password[2], '.', 'H'};
- /*
- // if password is fed in by a human we'd want to do this shit.... but we generate valid chars anyways, so why bother?
- for (int i = 0; i < b.length; i++) {
- if (b[i] < '.' || b[i] > 'z') {
- b[i] = '.';
- }
- for (int j = 0; j < search.length; j++) {
- if (b[i] == search[j]) {
- b[i] = replace[j];
- }
- }
- }
- */
- return salt;
- }
- private static char[] randChars(int len) {
- char[] res = new char[len];
- for (int i = 0; i < len; i++) {
- res[i] = CHARS[r.nextInt(CHARS.length)];
- }
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement