A UUID (Universally Unique Identifier) is a 128-bit number used to identify information in computer systems. Also known as GUID (Globally Unique Identifier) in Microsoft systems, UUIDs are essential for distributed computing where unique identification is crucial.
Why Use UUIDs?
**Uniqueness Without Coordination**: UUIDs can be generated independently without checking a central registry, making them perfect for distributed systems.
**Database Primary Keys**: UUIDs make excellent primary keys, especially in systems where data is created across multiple servers or needs to be merged later.
**API Resource Identification**: RESTful APIs commonly use UUIDs to identify resources in URLs, providing security through obscurity compared to sequential IDs.
**Session and Token Generation**: UUIDs are frequently used for session identifiers, authentication tokens, and temporary access codes.
UUID Version 4 Explained
Our generator creates UUID v4, the most commonly used version. UUID v4 uses random numbers for all bits except: - 4 bits for the version number (4) - 2-3 bits for the variant
The format is: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is 8, 9, A, or B.
With 122 random bits, the probability of generating duplicate UUID v4s is astronomically low—you'd need to generate 1 billion UUIDs per second for about 85 years to have a 50% chance of a collision.