UUID Generator (version 4)

Generate a Universally Unique IDentifier (UUID) version 4 (pseudo random), a random 128-bit identifier which can be considered unique. UUID is also known as Globally Unique IDentifier (GUID).

Generated UUID:

 

More about UUID version 4

UUID version 4 is generated using a pseudo-random or random number generator to create a 128-bit identifier. Here are the steps to generate a UUID version 4:

  1. Generate 16 bytes (128 bits) of random data using a secure random number generator. This data can be generated using cryptographic libraries, operating system APIs, or hardware random number generators.

  2. Set the version number. The version number for UUID version 4 is 0100 in binary or 4 in hexadecimal. This value is set in the most significant 4 bits of the 7th byte of the UUID.

  3. Set the variant. The variant number for UUID version 4 is 10 in binary or 8, 9, A, or B in hexadecimal. This value is set in the most significant 2 bits of the 9th byte of the UUID.

  4. Combine the generated random data with the version number and variant number to form a 128-bit UUID.

  5. Format the UUID as a string of 32 hexadecimal digits, grouped in five sections separated by hyphens. The format of the string is typically: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where each x represents a hexadecimal digit and y is a hexadecimal digit that represents the variant.

Here's an example of how a UUID version 4 might be generated:

  1. Generate 16 bytes of random data: 6c 8c 75 1f 0d aa a7 21 98 c1 46 11 10 f2 03 67.

  2. Set the version number: 0100.

  3. Set the variant number: 1000 (or 8, 9, A, or B in hexadecimal).

  4. Combine the random data, version number, and variant number to form the UUID: 6c8c751f-0daa-4217-98c1-461110f20367.

  5. The resulting UUID is a unique identifier that is very unlikely to be duplicated.

Note that while UUID version 4 is very likely to be unique, it is not guaranteed to be unique in every circumstance. In rare cases, it is possible to generate duplicate UUIDs if two systems generate the same random data at the same time. However, the probability of generating a duplicate UUID is extremely low.