I\'d like to set non-integer primary keys for a table using some kind of hash function. md5() seems to be kind of long (32-characters).
What are some alternative
You can use something like base 32 notation. It is more compact than decimal notation, case insensitive and collision-free. Just encode a plain old sequence number to generate a short hash-like code.
If the key is not for human consumption, you can use base 64 notation, which is case sensitive but a little more compact.
See http://code.google.com/p/py-cupom/ for an example.