05
This commit is contained in:
28
05/05-1.py
Normal file
28
05/05-1.py
Normal file
@@ -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')
|
||||
29
05/05-2.py
Normal file
29
05/05-2.py
Normal file
@@ -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')
|
||||
Reference in New Issue
Block a user