I have a database of entities that I want to display in a web ui. I want a short, alphanumeric string that I can generate from the entity's key. I came to the conclusion that base32 was a good solution (particularly because I wanted the keys to be case-insensitive so they could be read verbally, etc). Is there anything shorter or more space efficient than the below?
import base64
def b32urlencode(x):
return base64.b32encode(x).strip('=').lower()
def b32urldecode(x):
return base64.b32decode(x + ('=' * (8 - (len(x) % 8))))