Since you want the "number" (yes, a md5 hash is nothing but a base16 number, we can of course convert that to base-something to shorten the string) to be pronouncable over the phone, I suggest avoiding mixed upper- / lowercase.
And when we only allow [0-9A-Z], we can simply use the builtin int() with Base36 for decoding.
See:
>>> def encode(num):
import string
ALPHABET = string.digits + string.ascii_uppercase
tmp = []
while num:
num, rem = divmod(num, len(ALPHABET))
tmp.append(ALPHABET[rem])
return ''.join(reversed(tmp))
>>> import hashlib
>>> the_hash = hashlib.md5('test').hexdigest()
>>> decimal_representation = int(the_hash, 16)
>>> encoded = encode(decimal_representation)
>>> the_hash
'098f6bcd4621d373cade4e832627b4f6'
>>> decimal_representation
12707736894140473154801792860916528374L
>>> encoded
'KDISMNX5MOYU6Q6PZT8TQDPY'
>>> decimal_representation == int(encoded, 36)
True
>>> hex(int(encoded, 36))
'0x98f6bcd4621d373cade4e832627b4f6L'
You could of course use a longer alphabet to shorten the resulting string, but then you'd have to write your own decode() function. Should not be too hard, though.