Your unlisted paste is one +1 away from a stranger
transcript
You share a paste by link. Unlisted. Nobody else should find it. A stranger reads it anyway. All they did was add one.
For unlisted pastes, the link is the only protection. So the ID isn't just a name. It's the key to the door.
The obvious choice: a counter in base 62. Short. Never collides. But it's sequential. Try the next ID, and the next. Read every unlisted paste. So pick 8 random characters. Unguessable. No coordination between servers. The cost? Now and then, a collision. And a retry.
8 base 62 characters? About 2 point 2 times 10 to the 14 IDs. Five years of pastes: about 1 point 8 billion. So a new ID collides about 1 time in 120,000. Insert if absent. If taken, retry.
But here's the catch. Not every random is random. A generator seeded with the time makes IDs guessable again. Use a cryptographically secure generator. Every time.
A sequential ID is a list of everyone's pastes. When the link is the lock, make it unguessable. Short comes second.
Full breakdown in the lecture.