HNHacker News
TopNewBestAskShowJobs

tmpyt

10 karma · joined December 4, 2020

submissionscomments
tmpyt··on Pg-shortkey: YouTube-Like Short IDs as Postgres Primary Keys
On youtube, uploaders can switch their videos to be public/private/unlisted anytime, you can't rely on this status to be set in stone at upload.
tmpyt··on Pg-shortkey: YouTube-Like Short IDs as Postgres Primary Keys
That's exactly what youtube originally did - video id is just an encrypted (3DES, iirc) 64-bit sequential primary key straight from mysql database. You can convert it back and forth. Problem: if you know the encryption key (it was sitting right there in the code for all devs to see, easy to steal) you could enumerate all the YT videos, including all unlisted videos. At least until a few years ago - they've since switched to random database keys instead of autoincrement to fix this exact hole.

Source: worked there.