Created
December 4, 2015 20:12
-
-
Save g-cassie/0804e3d80f8f12d97fa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import md5 | |
def find_key(secret): | |
""" | |
>>> find_key('abcdef') | |
609043 | |
>>> find_key('pqrstuv') | |
1048970 | |
""" | |
key = '' | |
current_number = 1 | |
while key[0:5] != '00000': | |
key = md5.new(secret + str(current_number)).hexdigest() | |
current_number += 1 | |
return current_number - 1 | |
def find_key_p2(secret): | |
key = '' | |
current_number = 1 | |
while key[0:6] != '000000': | |
key = md5.new(secret + str(current_number)).hexdigest() | |
current_number += 1 | |
return current_number - 1 | |
if __name__ == "__main__": | |
import doctest | |
doctest.testmod() | |
print 'Answer is: ' + str(find_key('yzbqklnj')) | |
print 'Second Answer is: ' + str(find_key_p2('yzbqklnj')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment