[Yanel-dev] Unique IDs

Cedric Staub cedric.staub at wyona.com
Wed Jan 12 15:16:58 CET 2011


On Wed, Jan 12, 2011 at 01:29:12PM +0000, Nigel Runnels-Moss wrote:
> There are issues with UUID shortening, not least of which they cease to
> become unique...

Actually you can make UUIDs shorter while still preserving the full set
of information by simply switching to a higher-base encoding. Normally a
UUID is encoded with base 16 (hex), but that can easily be changed ;-).

If you use e.g. 64 characters you can do a base 64 encoding, where each
character would represent 6 bits of information as opposed to the 4 bits
of information for each character in a base 16 encoding.

Since UUIDs carry 128 bits of information switching from a base 16 to a
base 64 encoding would allow one to shorten the length of the encoding
down to 22 characters instead of the original 32.

Switching to an encoding with an even higher base would allow for an
even shorter UUID, but it's actually quite difficult to find more than
64 printable ASCII characters. There's an implementation of an encoding
that uses 85 characters to achieve a base 85 encoding, but it is very 
human-unfriendly because it starts to include funny characters. However,
it would allow one to cut down the size of the UUID to 20 characters.

Cheers
Cedric


More information about the Yanel-development mailing list