UUID / GUID 生成器
批量生成 UUID v4(随机)或 v1(基于时间)标识符。密码学安全,无追踪,无需数据库。
UUID versions
| Version | How it is generated | Use when |
|---|---|---|
| v1 | Timestamp + MAC address | You need sortable, non-random IDs |
| v3 | MD5 hash of a namespace + name | Deterministic IDs from names (rare) |
| v4 | 122 random bits | The default choice for most apps |
| v7 | Timestamp + random, time-sortable | Newer databases, event streams |
Why v4 is the default choice
UUID v4 draws 122 bits from a cryptographically secure source. There is no ordering and no machine fingerprint, which avoids two classic problems: v1 IDs leaked the MAC address of the generating machine, and they can be sorted back into creation order.
The trade-off is that v4 IDs are not sortable. If you are storing UUIDs as primary keys in a large database, the random ordering causes write amplification in B-tree indexes. In that case, consider UUID v7 or a simple auto-increment integer instead.
The format
550e8400-e29b-41d4-a716-446655440000
^^^^^^^^ ^^^^ ^^^^ ^^^^ ^^^^^^^^^^^^^^^
time_low time_mid ver clock node
In v4 the dashes split the 128 bits into 8-4-4-4-12 groups for readability. The 13th hex digit of the third group encodes the version, and the 17th hex digit of the fourth group encodes the variant.
How this tool generates them
Using crypto.getRandomValues() or crypto.randomUUID() when available — never Math.random(). IDs are generated entirely in your browser and are never transmitted or logged.
常见问题
Are the UUIDs truly random?
Yes, version 4 draws 122 bits from crypto.getRandomValues(). They contain no timestamp and no machine identifier.
Should I use UUID v4 or v7?
Use v4 unless you are storing them as database primary keys at scale. Random v4 keys cause write amplification in B-tree indexes; v7 is time-sortable and avoids that.
Can a UUID v4 collide?
In principle yes, but the probability is vanishingly small. With 122 random bits, the chance of a collision in a billion records is roughly one in ten million.
Is a UUID the same as a GUID?
Functionally yes. UUID is the standard term; GUID is Microsoft's original implementation of the same concept.
Should I use a UUID as a security token?
Not on its own. A v4 UUID has 122 bits of randomness, which is strong, but it is not designed for secret material. Use a dedicated secret generator for tokens.