Skip to content

Instantly share code, notes, and snippets.

@smaspe
Last active August 29, 2015 14:11
Show Gist options
  • Save smaspe/fc68854880684b62f075 to your computer and use it in GitHub Desktop.
Save smaspe/fc68854880684b62f075 to your computer and use it in GitHub Desktop.
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