-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday5_2.py
More file actions
25 lines (19 loc) · 729 Bytes
/
day5_2.py
File metadata and controls
25 lines (19 loc) · 729 Bytes
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
import itertools
import hashlib
data = 'uqwqemis'
key = ['_', ] * 8
for a in itertools.count():
to_hash = (data + str(a)).encode('ascii')
hashed = hashlib.md5(to_hash).hexdigest()
if hashed[:5:] == '00000':
position = hashed[5]
keydigit = hashed[6]
if ord(position) >= ord('0') and ord(position) <= ord('7'):
position = int(position)
if key[position] == '_':
key[position] = keydigit
print('Found key digit at {}: {} at position {}'.format(a, keydigit, position))
print('Current key: {}'.format(''.join(key)))
if '_' not in key:
break
print('Found key: {}'.format(''.join(key)))