แฮช/การเข้ารหัส
UUID Generator
สร้าง UUID เวอร์ชัน 1, 3, 4, 5, 6 และ 7 — แบบสุ่ม แบบอิงเวลา และแบบอิงชื่อ (name-based)
A UUID (Universally Unique Identifier) is a 128-bit identifier that's unique in practice without a central registry: two independent servers can generate one at the same moment and almost never collide. The versions differ in how they're generated.
Which version to pick
- v4 — fully random, the most common choice for database record IDs, session keys, and similar cases.
- v1 and v6 — based on creation time; v6 carries the same content as v1 but with the fields reordered so it sorts naturally — handy as a primary key.
- v3 and v5 — deterministic, derived from a namespace and a name (v3 uses MD5, v5 uses SHA-1) — the same input always produces the same UUID.
- v7 — the newest standard: a millisecond Unix timestamp plus a random part, sortable by time like v1/v6, but without a MAC address.
Common uses
- Primary keys in databases where auto-increment doesn't fit (distributed systems, offline-first apps).
- Session IDs, request IDs for tracing, temporary file names.
- Deterministic IDs (v5) for objects that need the same identifier across different systems given the same name.
Things to keep in mind
UUID v1 and v6 embed the generating device's MAC address — avoid them if that's an unwanted disclosure.
The format is 32 hexadecimal characters grouped with hyphens as 8-4-4-4-12 (e.g. 550e8400-e29b-41d4-a716-446655440000).
บทความเกี่ยวกับเครื่องมือนี้: UUID: ตัวระบุที่แทบไม่เคยซ้ำกันถูกสร้างขึ้นอย่างไร
คำถามที่พบบ่อย
UUID v4 ต่างจากเวอร์ชันอื่นอย่างไร?
UUID v4 สร้างจากตัวเลขสุ่มหรือกึ่งสุ่ม ทำให้เป็นตัวเลือกที่ง่ายที่สุดโดยไม่ขึ้นกับเวลาหรือตัวระบุฮาร์ดแวร์ เวอร์ชันอื่นอย่าง v1 เข้ารหัสไทม์สแตมป์และที่อยู่ MAC หรือ v5 สร้าง UUID แบบกำหนดแน่นอนจากเนมสเปซและชื่อ
UUID สองตัวที่สร้างขึ้นมีโอกาสชนกันมากแค่ไหน?
ต่ำมาก UUID v4 มีบิตสุ่ม 122 บิต จึงต้องสร้าง UUID นับพันล้านตัวต่อวินาทีนานนับศตวรรษ ก่อนที่การชนกันจะมีโอกาสเกิดขึ้นในทางสถิติ
UUID ที่สร้างที่นี่ถูกส่งไปที่ไหนหรือไม่?
ไม่ การสร้างทั้งหมดเกิดขึ้นในเบราว์เซอร์ของคุณโดยใช้แหล่งข้อมูลสุ่มที่ปลอดภัยเชิงรหัสลับ ไม่มีข้อมูลใดถูกส่งไปยังเซิร์ฟเวอร์
UUID v7 คืออะไร และดีกว่า v4 สำหรับฐานข้อมูลอย่างไร?
UUID v7 ฝังการประทับเวลาไว้ในบิตแรก ทำให้ค่าต่าง ๆ เรียงลำดับตามเวลาที่สร้างขึ้นตามธรรมชาติ — ต่างจาก v4 ที่สุ่มอย่างสมบูรณ์ซึ่งส่งผลเสียต่อประสิทธิภาพของดัชนีฐานข้อมูลเนื่องจากลำดับการแทรกระเบียนใหม่ที่ไม่เป็นระเบียบ
สามารถใช้ UUID เป็นโทเคนลับได้หรือไม่?
สำหรับ UUID v4 ได้ เนื่องจากถูกสร้างขึ้นด้วยตัวสร้างความสุ่มที่แข็งแกร่งเชิงรหัสลับ แต่ UUID v1 เผยให้เห็นบางส่วนของเวลาที่สร้างและที่อยู่ MAC ของอุปกรณ์ จึงไม่เหมาะกับกรณีที่ต้องการความคาดเดาไม่ได้