How can I encode an integer with base 36 in Python and then decode it again?
terrible answer, but was just playing around with this an thought i'd share.
import string, math
int2base = lambda a, b: ''.join(
[(string.digits +
string.ascii_lowercase +
string.ascii_uppercase)[(a // b ** i) % b]
for i in range(int(math.log(a, b)), -1, -1)]
)
num = 1412823931503067241
test = int2base(num, 36)
test2 = int(test, 36)
print test2 == num