-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAoCDay4.java
29 lines (28 loc) · 895 Bytes
/
AoCDay4.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.nio.*;
import java.nio.file.*;
import java.io.*;
import java.util.*;
import java.security.*;
import java.math.BigInteger;
public class HelloWorld{
public static void main(String []args) throws GeneralSecurityException, UnsupportedEncodingException {
String code = "bgvyzdsv";
boolean found = false;
int i = 0;
while(found == false) {
String text = code.concat(Integer.toString(i));
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(text.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashText = bigInt.toString(16);
if(hashText.length() == 27) {
found = true;
} else {
i++;
}
}
System.out.println(i);
}
}