Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.security.MessageDigest;
- /**
- * @author /u/Philboyd_Studge
- */
- public class Advent4 {
- public static boolean check(byte[] b, boolean part1) {
- return (b[0] | b[1] | (part1 ? (b[2] >> 4 & 0xf) : b[2])) == 0;
- }
- public static void main(String[] args) throws Exception {
- MessageDigest md = MessageDigest.getInstance("MD5");
- String test = "ckczppom";
- int pad = 1;
- long time = System.currentTimeMillis();
- while (true) {
- byte[] md5 = md.digest((test + pad++).getBytes());
- if (check(md5, false)) break; // true for part1, false for part2
- }
- System.out.println(pad - 1);
- System.out.println("Time: " + (System.currentTimeMillis() - time));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment