UUID generator and decoder (v4, v7) hakkında
A UUID is a 128-bit identifier written as 32 hex digits in 8-4-4-4-12 groups. RFC 9562 fixes two fields in every standard UUID: the variant bits 10 at the start of the 17th hex digit, and a 4-bit version number in the 13th. The decoder reads both, then unpacks what that version carries: a 48-bit Unix millisecond timestamp for version 7, a 60-bit count of 100-nanosecond intervals since 15 October 1582 for versions 1 and 6, or 122 random bits for version 4.
The default is the RFC 9562 version 7 example, 017f22e2-79b0-7cc3-98c4-dc0c0c07398f, whose first 48 bits count 1,645,557,742,000 ms, which is 22 February 2022 at 19:22:22 UTC. Developers pick v7 for database keys because the values sort by creation time.
Generated UUIDs come from a seeded xoshiro256** generator, so the same seed always gives the same list. For identifiers that must be unguessable, use a cryptographic source such as crypto.randomUUID().
Sorular
What is the difference between UUID v4 and v7?
Version 4 fills 122 of the 128 bits with random data, so values are spread evenly and reveal nothing. Version 7, defined in RFC 9562 (May 2024), puts a 48-bit Unix millisecond timestamp first and 74 random bits after it, so new IDs sort in creation order. RFC 9562 notes that v4 has poor database-index locality, which is why v7 suits primary keys, at the cost of revealing when each ID was made.
Can two random UUIDs collide?
In practice, no. A v4 UUID has 122 random bits, so by the birthday bound you would need about 2.7 × 10^18 of them for a 50% chance of a single duplicate, or about 103 trillion for a one-in-a-billion chance. Real collisions come from faulty random number generators or reused seeds, which is why the seeded UUIDs here shouldn't be used where uniqueness across systems matters.
What is the difference between a UUID and a GUID?
They are the same 128-bit format; GUID is Microsoft's name for it. Microsoft tools often print GUIDs in upper case inside braces, such as {017F22E2-79B0-7CC3-98C4-DC0C0C07398F}, and RFC 9562 allows upper, lower or mixed case, so parsers should accept both. The one real difference is binary byte order: Windows stores the first three groups little-endian, which matters only when reading raw bytes.
How do I get the timestamp from a UUID v7?
Take the first 12 hex digits, which hold a 48-bit count of milliseconds since 1970-01-01 00:00 UTC, and convert them to decimal. For 017f22e2-79b0-7cc3-98c4-dc0c0c07398f, 017f22e279b0 is 1,645,557,742,000 ms, which is 2022-02-22 19:22:22.000 UTC. The 48-bit field runs out in the year 10889, so it will not wrap in practice.
Is a version 1 UUID a privacy risk?
It can be. Version 1 stores a 60-bit timestamp and a 48-bit node field that is traditionally the machine's MAC address, so the ID reveals when and on which network card it was made; the RFC 9562 v1 example decodes to 2022-02-22 19:22:22 UTC with node 9f:6b:de:ce:d8:46. RFC 9562 allows a random node value instead, and says to use version 7 instead of 1 or 6 where possible.
“UUID generator and decoder (v4, v7)” ne kadar doğru sonuç verir?
Doğruluk, girdilerinize ve yöntemin varsayımlarına bağlıdır. Ondalık aritmetik 50 anlamlı basamak kullanır; ancak tahminler, sayısal yöntemler ve kaynak veriler daha az hassas olabilir. Gösterilen değerin yuvarlanması bu sınırları ortadan kaldırmaz. Bağımsız kaynaklarla doğrulanan çözümlü örnek sayısı: 8. Örneğin “RFC 9562 version 7 example”, RFC 9562 Appendix A.6 (Tuesday, February 22, 2022 2:22:22.00 PM GMT-05:00); Python 3.8: int('017F22E279B0', 16) = 1645557742000 ile karşılaştırılarak doğrulanır.
Yöntemin kaynağı nedir?
RFC 9562 — Universally Unique IDentifiers (UUIDs), §4–5 and Appendix A test vectors; Blackman & Vigna — xoshiro256** and SplitMix64 reference code.