February 2020
Intermediate to advanced
404 pages
8h 42m
English
The Base62 algorithm is a number encoder that converts a given number to a string. How does it do that? The input number is mapped from 62 characters. The beauty of this algorithm is that it creates unique, shorter strings for every given number. It can generate memorable short strings, even when the inputs are big. We use this technique to pass a database ID into the ToBase62 function—which we are going to create shortly—and get a short string out. Let's write an example for implementing the Base62 algorithm. The logic is purely mathematical and can be implemented in different ways. Proceed as follows:
mkdir $GOPATH/src/github.com/git-user/chapter7/base62Example ...
Read now
Unlock full access