Skip to content

nandoflorestan/livid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raison d'etre

GUID and UUID are not good ID schemes for the web because they are not designed for human consumption. They are too long and too hard to type, therefore not adequate for a URL. Youtube solved this problem perfectly with their 11-character video IDs, which:

  • are short,
  • are as easy to type as is realistic to hope for, and
  • contain a lot of information in them.

Now you wish to use the same scheme in your application.

  • Below is a specification. It is identical to what YouTube does, as far as we know. Let us call it "Livid".
  • This project contains implementations of the spec:
    • in Dart (TODO)
    • in Javascript (TODO)
    • in Python

Livid specification

Length and alphabet

Bit structure and payload

  • Encodes a 64-bit integer payload.
  • 11 Base64 characters ≈ 66 bits; only about 64 bits carry payload.
  • The last character is restricted to 16 possible values to zero out unused bits.

The regular expression pattern for valid IDs is [A-Za-z0-9_-]{10}[AEIMQUYcgkosw048].

Encoding process

  1. Generate a random 64-bit unsigned integer.
  2. Encode in Base64, producing an 11-character string.
  3. If the integer collides with an existing ID, regenerate. Collisions are extremely rare in such a large space.

Collision and randomness strategy

  • IDs are randomly generated, not sequential, to avoid enumeration, scraping, and privacy leaks (reddit.com).
  • Collision-checking ensures uniqueness.

Validity and guaranteed uniqueness


Summary table

Feature Description
Length Exactly 11 chars
Character set [A–Z][a–z][0–9][- _]
Encoded data 64-bit + 2 unused bits
End-char restrictions Only 16 values (last 2 bits zeroed)
Generation method Random + Base64 URL-safe encoding
Collision handling Check uniqueness, retry on conflict
Validation Query the server/API
Guarantee No official guarantee on format stability

About

URL-friendly IDs for your app, like YouTube's

Topics

Resources

License

Stars

Watchers

Forks