ハッシュ/暗号
UUID Generator
バージョン 1、3、4、5、6、7 の UUID を生成 — ランダム、時刻ベース、名前ベース(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 v4と他のバージョンの違いは何ですか?
UUID v4はランダムまたは疑似ランダムな数値から生成されるため、時刻やハードウェア識別子に依存しない最もシンプルな選択肢です。v1のようなバージョンはタイムスタンプとMACアドレスを、v5は名前空間と名前からUUIDを決定論的に導出します。
生成された2つのUUIDが衝突する可能性はどのくらいですか?
極めて低いです。v4のUUIDは122ビットのランダム性を持つため、統計的に衝突が起こりうるまでには何世紀もの間、毎秒何十億ものUUIDを生成し続ける必要があります。
ここで生成されたUUIDはどこかに送信されますか?
いいえ。生成は暗号学的に安全な乱数源を使ってブラウザ内で完全に行われます。サーバーには何も送信されません。
UUID v7とは何で、データベースにおいてv4よりどう優れているのですか?
UUID v7は先頭ビットにタイムスタンプを埋め込むため、値が作成時刻順に自然にソートされます——一方、完全にランダムなv4は、新しいレコードの挿入順序が無秩序になるため、データベースインデックスの性能に悪影響を与えます。
UUIDを秘密のトークンとして使ってもよいですか?
UUID v4であれば可能です。暗号学的に安全な乱数生成器で生成されるためです。ただしUUID v1は作成時刻とデバイスのMACアドレスを部分的に露出するため、予測不可能性が求められる用途には適しません。