
UUID Generator Guide: Understanding v1, v4, and v5 UUIDs
UUID Generator Guide: Understanding v1, v4, and v5 UUIDs UUIDs (Universally Unique Identifiers), also called GUIDs in Microsoft systems, are 128-bit identifiers designed to be unique across space and time without requiring a central registry. What is a UUID? A UUID looks like this: 550e8400-e29b-41d4-a716-446655440000 Format: 8-4-4-4-12 hexadecimal digits (36 characters total including hyphens) Total combinations: 2^122 ≈ 5.3 × 10^36 (for version 4) To put this in perspective: If you generated 1 billion UUIDs per second, it would take over 100 billion years to have a 50% chance of a collision. UUID Versions Explained UUID v1: Timestamp-based Format: xxxxxxxx-xxxx-1xxx-yxxx-xxxxxxxxxxxx Generated from: Current timestamp (60-bit) Clock sequence (14-bit) MAC address (48-bit) Example: // Node.js with uuid package import { v1 as uuidv1 } from ' uuid ' ; const id = uuidv1 (); // '6c84fb90-12c4-11e1-840d-7b25c5ee775a' Pros: Time-ordered (sortable by creation time) Reveals creation timestamp C
Continue reading on Dev.to Webdev
Opens in a new tab


