How can the Google URL shortener generate a unique hash with five characters without collisions. Seems like there are bound to be collisions, where different urls generate the same hash.

stackoverflow.com => https://stackoverflow.com/

What's also interesting, is the same URL, generates a completely different hash each time:

stackoverflow.com => https://stackoverflow.com/questions

So, doing some math, using lower-case characters, upper-case characters, and digits, the total number of combinations are 62^5 = 916,132,832 clearly collisions bound to happen.

How does Google do this?

Edit
Report