How is an UUID / GUID made

General

An UUID is basically just a 128 bit number, the structure, and the way it is constructed is determined by the variant and the version. The correct way to construct these identifiers is described in RFC 4122 the contents of this document is my interpretation of that document. These pages intend to give a simpler explanation of what is written in the Leach, Mealling and Salz draft.

Variants

To accomodate for past mistakes and future improvements a variant is encoded into the UUID. The variant is stored in the most significant bits of the fourth group. Currently known variants are:
  • 0 NCS (reserved for backward compatibility)
  • 10 The current variant, described used and produced on these pages.
  • 110 Microsoft (reserved for backward compatibility)
As can be seen the variant can currently not start with 111, all variants starting with 111 are reserved for future use.

The variant can be extrected from the UUID, after doing some work: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The bit representation of hexadecimal number 96 is 10010110. This number starts with 10 and therefore is an UUID constructed according to the current variant. One should currently not encouter UUIDs with E or F on the position of the (underlined, big, fat) 9 in this example, as these variants are reserved for future use. In the current variant this group starts with a 8, 9, a or b.

Versions

In the current variant 5 basic types "versions" of UUIDs are in used.
  1. Time-based with unique or random host identifier
  2. DCE Security version (with POSIX UIDs)
  3. Name-based (MD5 hash)
  4. Random
  5. Name-based (SHA-1 hash)
The version can easily be recognised as it is stored as the first digit of the third group: 58e0a7d7-eebc-11d8-9669-0800200c9a66
Every version is made in its own way.

How is a Time-based UUID made

How is a Name-based UUID made

How is a Random UUID made

What is an UUID

I need an UUID

If you have improvements, contact information on the homepage of this host.
An agent adding logging to your java programs at runtime
The uptime of home.famkruithof.net


Search for more information :
Google