AG UUID

Collision probability and security

A look at whether UUIDs are truly unique and whether they are safe to use as security tokens.

Collision probability

v4 is 122 random bits, giving 5×10³⁶ possibilities. Collisions effectively never happen at any realistic scale, but you must generate them from a cryptographic random source (getRandomValues).

Predictability

v1 and v7 include a timestamp, so the creation time can be inferred. For session or secret tokens that must be hard to guess, it is safer to use v4 or a dedicated token generator.

Security note

A UUID only guarantees "uniqueness," not "secrecy." For authentication and authorization, use a UUID only as a unique key, and manage secret values with a separate security token.