30 lines
739 B
Python
30 lines
739 B
Python
![]() |
#!/usr/bin/env python
|
||
|
|
||
|
import argparse
|
||
|
import hashlib
|
||
|
|
||
|
def main(args):
|
||
|
seq = 0
|
||
|
password = ""
|
||
|
|
||
|
|
||
|
while True:
|
||
|
char_input = "{}{}".format(args.input, seq)
|
||
|
m = hashlib.md5()
|
||
|
m.update(char_input.encode('utf-8'))
|
||
|
h = m.hexdigest()
|
||
|
if h.startswith('00000'):
|
||
|
password = "{}{}".format(password, h[5])
|
||
|
print("id: {}, hash: {}".format(seq, h))
|
||
|
if len(password) == 8:
|
||
|
break;
|
||
|
seq += 1
|
||
|
print(password)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
parser = argparse.ArgumentParser(description='AdventOfCode 2016 Day 01')
|
||
|
parser.add_argument('--input', '-i', action='store', required=True, help='input file')
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
main(args)
|