Introduction to UUID

UUID Definition

A Universally Unique Identifier (UUID) is a 128-bit identifier used to uniquely identify information in computer systems. When generated using standard methods, UUIDs exhibit uniqueness in practical applications and do not rely on central registration and allocation authorities. The probability of UUID duplication is close to zero and can be considered negligible.

As a result, anyone can create and use UUIDs independently, and it is almost certain that they will not collide with existing identifiers. Because of this, UUIDs generated in different locations can be used in the same database or channel, with minimal risk of duplication.

Introduction to UUID Versions

Standard Format:

The format of a UUID is as follows: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx. N can only be 8, 9, a, or b. M represents the version number, and since UUID's standard implementation has five versions, it will be one of 1, 2, 3, 4, or 5.

Version 1: Time-based UUID

Generated based on the current timestamp and machine MAC address. This version ensures global uniqueness due to the use of MAC addresses in the algorithm. However, it exposes the computer's MAC address and the time of UUID generation, making it a criticized aspect of this UUID version.

Version 2: DCE Security UUID

DCE Security UUID shares the algorithm with the time-based UUID but replaces the first 4 positions of the timestamp with POSIX UID or GID. However, the UUID specification does not explicitly define this version, so most UUID implementations do not support it.

Version 3: Name-based UUID (MD5)

User-specified namespace and a specific string are used to generate a UUID through MD5 hashing. According to the specification, this version exists for backward compatibility and is rarely used in practice.

Version 4: Random Number-based UUID

UUID generated based on random or pseudo-random numbers. This version is the most commonly used.

Version 5: Name-based UUID (SHA1)

Similar to Version 3, but the hashing function is replaced with SHA1.