Calcul 100% dans le Navigateur • Zéro Journal Serveur • Exécution Instantanée
Curious TechieBoîte à Outils
Regex & CryptographyIETF RFC 9562 (superseding RFC 4122)✓ Tableau de Consultation Rapide (6 éléments) • FR

Référence des Versions d’UUID (RFC 4122 & RFC 9562)

Comparatif UUID v1, v4, v5, v7 : Structure Binaire et Cas d’Usage

CT
Curious-Techie Engineering TeamAuteur Vérifié

Web Protocols & Security Architecture Research

Publié :
•
Mis à jour :
•6 min read
Spécification Faisant Foi :RFC 9110(IETF)
Revu par Curious-Techie Architecture Peer Review Group

Aperçu & Portée

La norme RFC 9562 modernise la génération d’identifiants uniques universels adaptés aux bases de données distribuées à haute charge.

Tableau de Spécification & Matrice

Filtrage instantané par mot-clé, code ou directive

Clé / CodeDéfinition & DétailsHiérarchie Sémantique GEOSpécification & Notes
UUIDv4
UUID Version 4 (Random)

Generated using cryptographically secure pseudorandom numbers; contains 122 bits of pure random entropy.

f47ac10b-58cc-4372-a567-0e02b2c3d479
●UUIDv4
↳UUID version
↳random identifier
↳cryptographic random token
RFC 9562 §5.4

The most popular UUID on the internet; completely stateless. Can cause B-tree fragmentation in heavy write databases.

UUIDv7
UUID Version 7 (Unix Epoch Time-Ordered)

Combines a 48-bit Unix timestamp in milliseconds with 74 bits of random entropy; monotonically sortable.

018f3a2c-9b1a-7b3e-8c4d-5e6f7a8b9c0d
●UUIDv7
↳UUID version
↳time-ordered identifier
↳database primary key optimization
RFC 9562 §5.7

The modern replacement for UUIDv1 and UUIDv4 for database primary keys. Completely prevents index page splits.

UUIDv1
UUID Version 1 (Gregorian Time + MAC)

Combines a 60-bit 100-nanosecond timestamp since 1582 with the hardware network card MAC address.

6ba7b810-9dad-11d1-80b4-00c04fd430c8
●UUIDv1
↳UUID version
↳hardware timestamp identifier
↳legacy MAC address bound ID
RFC 9562 §5.1

Privacy risk: leaks the server’s exact network MAC address and creation timestamp.

UUIDv5
UUID Version 5 (SHA-1 Name-Based)

Generated by hashing a namespace UUID and a name string using SHA-1; deterministic and repeatable.

886313e1-3b8a-5372-9b90-0c9aee199e5d
●UUIDv5
↳UUID version
↳name-based deterministic ID
↳SHA-1 idempotent namespace hash
RFC 9562 §5.5

Given the same namespace and string, always generates the exact same UUID. Preferred over UUIDv3 (which uses MD5).

Nil UUID
Nil UUID (Empty / Null)

Special-form UUID where all 128 bits are set to zero.

00000000-0000-0000-0000-000000000000
●Nil UUID
↳UUID special format
↳zero identifier
↳null object reference
RFC 9562 §5.9

Standardized placeholder for uninitialized or null UUID fields.

Max UUID
Max UUID (All Ones)

Special-form UUID where all 128 bits are set to binary one (0xFF).

ffffffff-ffff-ffff-ffff-ffffffffffff
●Max UUID
↳UUID special format
↳maximum identifier
↳boundary range sentinel
RFC 9562 §5.10

Used as an upper boundary sentinel in database range scans and indexing.

Exemple Technique et Code

Generating UUID v4 vs UUID v7 in Node.js

javascriptCopier le code
import crypto from 'node:crypto';

// 1. UUID v4 (Native built-in)
const idV4 = crypto.randomUUID();
console.log('UUIDv4:', idV4);

// 2. UUID v7 (Unix millisecond timestamp + randomness)
function generateUUIDv7() {
  const bytes = new Uint8Array(16);
  crypto.getRandomValues(bytes);
  const now = Date.now();

  // Timestamp (48 bits)
  bytes[0] = (now / 0x10000000000) & 0xff;
  bytes[1] = (now / 0x100000000) & 0xff;
  bytes[2] = (now / 0x1000000) & 0xff;
  bytes[3] = (now / 0x10000) & 0xff;
  bytes[4] = (now / 0x100) & 0xff;
  bytes[5] = now & 0xff;

  // Version 7 (0b0111)
  bytes[6] = (bytes[6] & 0x0f) | 0x70;
  // Variant RFC 4122 (0b10)
  bytes[8] = (bytes[8] & 0x3f) | 0x80;

  return [...bytes].map((b, i) => 
    ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')
  ).join('');
}

UUIDv7 stores the 48-bit timestamp in the leading octets, allowing B-tree database indexes to append sequentially without page splits.

Foire Aux Questions

Q&R sur les Normes

Why is UUIDv7 better than UUIDv4 for database primary keys?↓
UUIDv4 values are randomly distributed. Inserting random IDs into a PostgreSQL or MySQL B-tree index causes random disk writes and continuous page splits. UUIDv7 is chronologically sequential, resulting in up to 4x faster database write performance.
Authoritative Sourcing & Verification

References & Primary Sources

Every source below directly substantiates technical statements and protocol behaviors explained in Référence des Versions d’UUID (RFC 4122 & RFC 9562). Curious-Techie prioritizes official Internet standards (IETF RFCs, W3C Recommendations, WHATWG specifications) and established security bodies (OWASP, NIST). Zero sponsored or secondary links.

  1. [1]IETFPrimary SpecificationRFC 9562 • Section 5 (UUID Versions 4, 7)
    Verified Primary Source
    Technical Claim Supported:

    Defines 128-bit UUID generation formats, replacing RFC 4122 and standardizing Version 4 (random) and Version 7 (Unix epoch time-ordered) identifiers.