Golang implementation of bijective function algorithm used in url shorters, see: http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener I would continue your "convert number to string" approach. However you will realize that your proposed algorithm fails if your ID is a prime and greater than 52 . Theoretical background You need a Bijective Function f . This is necessary so that you