$tiny = base_convert($key, 10, 36);
As Wikipedia explains, "...the choice of 36 is convenient in that the digits can be represented using the Arabic numerals 0-9 and the Latin letters A-Z. Base 36 is therefore the most compact case-insensitive alphanumeric numeral system using ASCII characters...". Not to mention, it's the highest radix most languages support by default.
I built Onyx to maintain a list of files (as inode's) in a MySQL database table. Luckily, the inode's are stored in this table as auto incrementing BIGINT(20)'s, which are of course, base-10 encoded numbers:
CREATE TABLE files (
f_inode BIGINT(20) NOT NULL AUTO_INCREMENT,
...
INDEX inode_index ( f_inode ),
PRIMARY KEY ( f_inode ),
...
) TYPE=InnoDB;
Base-36 encoding my inode's is key because this means that I can easily, for example, convert base-10 inode 3,032 into "2c8" base-36 for a tiny URL. From there, it's simply a matter of using the base-36 encoded string in a tiny/shortened permalink URL to refer to the correct file/inode on Onyx. Yes, this is a poor example because I'm only saving 1 character in a supposedly shorter URL ("3032" vs "2c8"). However, this makes a lot more sense with larger base-10 numbers like 105,621,983 which condenses nicely into "1qvufz" base-36. Personally, I'd rather see /1qvufz on the end of a "tiny" URL than /105621983.
Enjoy.


Did you find this post helpful, or at least, interesting?