Advertisement
Guest User

Reibello AoC 5

a guest
Dec 5th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #aoc2016_5a.py
  2. import hashlib
  3. import itertools
  4.  
  5. key = "uqwqemis"
  6. pw = ['.','.','.','.','.','.','.','.']
  7. '''
  8. for x in itertools.count(0):
  9.    test_key = key + str(x)
  10.    hash_key = hashlib.md5(test_key.encode('utf-8')).hexdigest()
  11.    if hash_key[:5] == '00000':
  12.            pw += hash_key[5]
  13.            print(pw)
  14.            if len(pw) >= 8:
  15.                break
  16.  
  17.  
  18. print(pw)
  19.        
  20. '''
  21. for x in itertools.count(0):
  22.     test_key = key + str(x)
  23.     hash_key = hashlib.md5(test_key.encode('utf-8')).hexdigest()
  24.     if hash_key[:5] == '00000' and hash_key[5].isdigit():
  25.         position = int(hash_key[5])
  26.         if position < len(pw):
  27.             if pw[position] == '.':
  28.                 pw[position] = hash_key[6]
  29.                 print(pw)
  30.                 if '.' not in pw:
  31.                     break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement