Last active
October 1, 2016 10:06
-
-
Save ph87/73d68d024f0190855bad72667f2b8442 to your computer and use it in GitHub Desktop.
A script handle the quiz from https://www.v2ex.com/t/309785
This file contains 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
from md5 import md5 | |
PREFIX = 'v2ex' | |
LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' | |
TARGET = '3bed22f7f496e84b035a996522baa7594c27c7e5718a78bfddf9012904b70eb755d67f90c8de149ead7ee674b024f38c216642030c2d54cb1dd657dd66342c99c239f3c31fd399fc052a9b7861f2073d2b9f47811dd77fd544d570c34bf5f349d110389979571714694a5054238465ca38ba26c25fb1a32b4d0a3b93666b09b3' | |
prefix_md5 = md5(PREFIX).hexdigest() | |
hash_f = lambda s: md5(prefix_md5 + s + md5(s).hexdigest()).hexdigest() | |
def get_hash_str(): | |
for chunk in range(0, len(TARGET), 32): | |
yield TARGET[chunk: chunk + 32] | |
base = '' | |
for target in get_hash_str(): | |
for letter in LETTERS: | |
if hash_f(base+letter) == target: | |
base += letter | |
break | |
print base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment