What is UUID Decoding?
UUID decoding is the process of analyzing a UUID to extract information about its:
- Version: Which UUID version (1-8) based on 4 bits in position 48-51
- Variant: Which UUID variant (usually RFC 4122) based on bits 64-65
- Components: Extracting timestamp, node ID, or other data based on version
- Generation time: For time-based UUIDs (v1, v6, v7)
Example: 123e4567-e89b-12d3-a456-426614174000
is a Version 1 UUID created on 2018-10-03 09:45:32 UTC.
UUID Structure Overview
Format | Description |
---|---|
8-4-4-4-12 | 32 hex digits grouped with hyphens |
Version bits | Bits 48-51 (13th digit) |
Variant bits | Bits 64-65 (17th digit) |
The version number appears as the first hex digit in the third group (e.g., 123e4567-e89b-12d3-a456-426614174000
for version 1).
Decoding by UUID Version
Version | What can be decoded |
---|---|
UUID v1 |
|
UUID v3/v5 |
|
UUID v4 |
|
UUID v6 |
|
UUID v7 |
|
ULID |
|
Timestamp Extraction from UUIDs
UUID Type | Time Extraction Method | Epoch |
---|---|---|
UUID v1 | Combine bits 0-31, 32-47, and 48-59, reordering timestamp components | October 15, 1582 |
UUID v6 | Extract bits 0-59 (already in correct order) | October 15, 1582 |
UUID v7 | Extract bits 0-47 (Unix milliseconds) | January 1, 1970 |
ULID | Decode first 10 Base32 characters to get 48-bit Unix milliseconds | January 1, 1970 |
UUID Validation Rules
- Format check: 8-4-4-4-12 hexadecimal digits with hyphens
- Version check: 13th character must be 1-8
- Variant check: 17th character must be 8, 9, A, or B (for RFC 4122)
Regular expression for basic UUID validation:
^[0-9a-f]8-[0-9a-f]4-[1-8][0-9a-f]3-[89ab][0-9a-f]3-[0-9a-f]12$
Practical Applications
- Forensic analysis: Determining when IDs were created
- Debugging: Tracing system behavior through ID timestamps
- Auditing: Validating chronological integrity
- Security analysis: Detecting forged or manipulated IDs
- Data recovery: Reconstructing temporal relationships
- System migrations: Understanding legacy UUID implementation details
MAC Address Extraction (v1/v6)
For UUID v1 and v6, you can often extract the node identifier (MAC address) if it wasn't randomized during generation:
- Extract the last 12 hex digits (48 bits) from the UUID
- Format with colons as XX:XX:XX:XX:XX:XX
- Check if the MAC address is real or random by examining the multicast bit
If the first byte has bit 0x01 set, it's likely a randomized node ID rather than an actual MAC address.
Frequently Asked Questions
Can I determine exactly when a UUID v4 was created?
No. UUID v4 is purely random with no timestamp information. Time of creation cannot be determined from a UUID v4 value.
How accurate are timestamps in time-based UUIDs?
UUID v1/v6 timestamps have 100-nanosecond precision. UUID v7 and ULID have millisecond precision. However, actual system clock accuracy may vary.
Can I convert between UUID versions?
No, you cannot convert directly between versions while preserving the same identifier value. Different versions have fundamentally different structures.
Can I identify the computer that generated a UUID v1?
If the node ID wasn't randomized, a UUID v1 may contain the MAC address of the generating system. However, many modern implementations randomize this for privacy.
How can I tell if a UUID is valid?
Check the format (8-4-4-4-12 hex digits), verify the version digit (13th character) is 1-8, and confirm the variant bits (17th character is 8, 9, A, or B for RFC 4122 UUIDs).