Last active
August 29, 2015 14:11
-
-
Save smaspe/fc68854880684b62f075 to your computer and use it in GitHub Desktop.
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
import itertools | |
letters = "acdegilmnoprstuw" | |
value = 25180466553932 | |
def hsh(s): | |
return reduce(lambda h, char: h * 37 + letters.index(char), s, 7) | |
def unhash(val): | |
return unhash(val / 37) + letters[val % 37] if val > 7 else '' | |
tst = value | |
res = "" | |
while tst > 7: | |
index = tst % 37 | |
assert index < len(letters) | |
res = letters[index] + res | |
tst = tst / 37 | |
assert tst == 7 | |
assert hsh(res) == value | |
print "Found: " + res + " for hash " + str(value) | |
print unhash(value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment