I need to convert some data to base 29 before processing and I'm using this:
import string
def datatobase(data, base):
digs = string.digits + string.lowercase + string.uppercase
if base > len(digs):
return None
digits = []
x = int(data.encode("hex"), 16)
while x:
digits.append(digs[x % base])
x /= base
digits.reverse()
return ''.join(digits)
Problem is that this small code is slowing my program too much so what would you do to replace it?
A custom answer for base 29 only would be great too!