Consider we have an URL, and we want to compress it. Base62 way is to find the URL integer id in database, then we transfer the integer id into base62 code. Bascially, it is bijection mapping between [0…9] and [a…zA….Z0…9].
The number of [a…zA….Z0…9] is totally 62. From integer to base62 url, each time, we use integer modular 62 to get result in each position. Then we do integer divides 62 to move.
From base62 to integer, it is similar to how we calculate from binary to decimal. For example, zAb = 25*10^2+26*10^1+1*10^0.
Check my code on github: link