A version-4 UUID is 128 bits with two fixed fields
The canonical text is 32 hex digits in five groups, 8-4-4-4-12. Four bits in the third group say the version, and two bits in the fourth group say the variant. Version 4 fills the other 122 bits from a random source. Uppercase, braces, and a urn:uuid: prefix change the spelling, not those bits. A hash is a function of some content — see hash digest. A password is a secret drawn from a character set — see password generator. A UUID is an identifier, and it is not either of those.
What the groups, the version, and the variant each mean
Why the text form is five hex groups and not 128 separate flags
- The value is 16 bytes. The usual text writes them as hex with hyphens after 8, 12, 16, and 20 digits.
- That is 36 characters. Dropping the hyphens leaves 32 hex digits, the same 128 bits if a reader puts the hyphens back.
- A reader that requires the hyphenated form will reject the compact string even when the bits match.
- Hex a–f is case-insensitive for the value. Uppercase and lowercase are one identifier written two ways.
Why version 4 puts a 4 in the third group and 8, 9, a, or b in the fourth
- The version is the high 4 bits of byte 6, which is the first hex digit of the third group. Version 4 writes 4 there.
- The RFC 4122 variant is the top two bits of byte 8, set to 10. The first hex digit of the fourth group is then 8, 9, a, or b.
- Those six bits are not random. The other 122 bits are.
- A string that has a different digit in either of those places is some other version or variant, even if it has the same hyphens.
Why GUID and UUID name one layout and several spellings
- GUID is the name used on Windows for the same 128-bit identifier. UUID is the IETF name.
- The braced form {8-4-4-4-12} is a Microsoft spelling. The braces are not extra bits.
- urn:uuid: is a URN wrapper around the same 36-character body. The prefix is not part of the 128 bits.
- A uuid column stores 16 bytes and accepts several spellings. A character column stores whatever letters you wrote.
Why a version-4 value does not sort into the order it was created
- Version 1 stores a timestamp and a node. The high bits are time, so the text tends to increase with time, and it can reveal a clock or a MAC address.
- Version 4’s high bits are random. Lexicographic order is not creation order.
- Version 7, from RFC 9562, puts a Unix millisecond timestamp in the high bits and random bits after that, so new values sort after older ones.
- The nil UUID is 128 zero bits. It is a named sentinel, not a value drawn from the random space.
Where an identifier, a digest, and a secret part ways
A row id that must not leak the clock or the machine
Version 4 does not encode when the row was inserted or which host minted it. Version 1 can. A database unique constraint is still what refuses the rare clash; the generator never sees the table.
A string that will be copied into logs and URLs
Anyone who can see the UUID can name that row. It is not a password and not a signature. A digest changes when the content changes. A version-4 UUID stays put if the row is edited, because it was never a function of the row.