From 20900f23125999fc4286d1e37f2b83422a2ccd0e Mon Sep 17 00:00:00 2001 From: tebarius Date: Thu, 19 Dec 2024 21:44:29 +0100 Subject: [PATCH] 05 --- 05/05-1.py | 28 ++++++++++++++++++++++++++++ 05/05-2.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 05/05-1.py create mode 100644 05/05-2.py diff --git a/05/05-1.py b/05/05-1.py new file mode 100644 index 0000000..ecc133c --- /dev/null +++ b/05/05-1.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +door_id = "abbhdwsy" #real +#door_id = "abc" #example + +from time import time +import hashlib + +start_time = time() + + + +if __name__ == "__main__": + #result = hashlib.md5("abc3231929".encode()) + #print(result.hexdigest()) + + sol = "" + i = 0 + while len(sol) <8: + if hashlib.md5(f"{door_id}{i}".encode()).hexdigest().startswith("00000"): + temp = hashlib.md5(f"{door_id}{i}".encode()).hexdigest() + print(i, temp, temp[5]) + sol += temp[5] + i += 1 + + print(f"Part 1 - SolutionPassword: {sol}") + print(f'Runtime: {time()-start_time:.4f} s') \ No newline at end of file diff --git a/05/05-2.py b/05/05-2.py new file mode 100644 index 0000000..56364f0 --- /dev/null +++ b/05/05-2.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +door_id = "abbhdwsy" #real +#door_id = "abc" #example + +from time import time +import hashlib + +start_time = time() + + + +if __name__ == "__main__": + #result = hashlib.md5("abc3231929".encode()) + #print(result.hexdigest()) + + sol = ["-", "-", "-", "-", "-", "-", "-", "-"] + i = 0 + while "-" in sol: + if hashlib.md5(f"{door_id}{i}".encode()).hexdigest().startswith("00000"): + temp = hashlib.md5(f"{door_id}{i}".encode()).hexdigest() + if temp[5] in "01234567" and sol[int(temp[5])] == "-": + sol[int(temp[5])] = temp[6] + print(i, temp, temp[5], temp[6]) + i += 1 + + print(f"Part 2 - SolutionPassword: {"".join(sol)}") + print(f'Runtime: {time()-start_time:.4f} s') \ No newline at end of file