UUID v3 Generator
MD5 का उपयोग करके नाम-आधारित निर्धारक UUID v3 जनरेट करें
नेमस्पेस
6ba7b810-9dad-11d1-80b4-00c04fd430c8
नाम
जनरेट किया गया UUID v3
UUID v3 क्या है?
UUID v3 एक name-based UUID version है जो RFC 4122 में define किया गया है। Random data या timestamp के बजाय, यह deterministically दो inputs से UUID derive करता है: एक namespace UUID और एक name string। Namespace + name pair को MD5 use करके hash किया जाता है।
UUID v3 की key property determinism है: same namespace और name हमेशा identical UUID produce करेंगे, किसी भी machine पर, किसी भी समय। यह content-addressing के लिए suitable बनाता है।
UUID v3 MD5 hash function use करता है। MD5 security purposes के लिए cryptographically broken माना जाता है, इसलिए UUID v5 (जो SHA-1 use करता है) नए development के लिए generally preferred है।
Standard Namespaces
RFC 4122 चार pre-assigned namespace UUIDs define करता है। Standard namespace use करने से interoperability ensure होती है — दो independent implementations same namespace के भीतर same name के लिए same UUID v3 produce करेंगी:
| Namespace | UUID | के लिए Use करें |
|---|---|---|
| DNS | 6ba7b810-9dad-11d1-80b4-00c04fd430c8 | Fully qualified domain names (जैसे 'example.com') |
| URL | 6ba7b811-9dad-11d1-80b4-00c04fd430c8 | URLs और URIs (जैसे 'https://example.com/resource') |
| OID | 6ba7b812-9dad-11d1-80b4-00c04fd430c8 | ISO Object Identifiers (जैसे '1.2.840.113556') |
| X.500 | 6ba7b814-9dad-11d1-80b4-00c04fd430c8 | X.500 Distinguished Names (जैसे 'cn=John,dc=example,dc=com') |
आप किसी भी arbitrary UUID को custom namespace के रूप में भी use कर सकते हैं — उदाहरण के लिए, एक UUID v4 जो आप once generate करते हैं और अपने application में constant के रूप में embed करते हैं।
UUID v3 vs UUID v5
UUID v3 और UUID v5 structurally identical हैं — दोनों deterministic, name-based UUIDs हैं। केवल hash function differ करता है:
- MD5 hashing use करता है
- 128-bit output (UUID-sized)
- RFC 4122 में Defined
- MD5 cryptographically broken है
- सभी UUID libraries द्वारा Supported
- SHA-1 hashing use करता है
- 160-bit hash truncated to 128 bits
- RFC 4122 में Defined
- SHA-1 security use के लिए deprecated लेकिन MD5 से stronger
- सभी UUID libraries द्वारा Supported
सभी नए development के लिए UUID v3 पर UUID v5 prefer करें। SHA-1 hash MD5 से stronger है, और performance difference negligible है।
UUID v3 कब Use करें
UUID v3 (और v5) appropriate हैं जब आपको meaningful name से derived stable, reproducible identifier चाहिए — random ID के बजाय जो store और look up करनी हो:
Determinism को समझना
UUID v3 का determinism इसकी greatest strength और most important constraint दोनों है। किसी भी namespace UUID और किसी भी name string के साथ, output UUID completely fixed है।
हमेशा produces: 9073926b-929f-31c2-abc9-fad77ae3e8eb
यदि attacker namespace जानता है और name guess कर सकता है, तो वो UUID advance में compute कर सकता है। UUID v3 values कभी भी unpredictable tokens, session IDs, या secrets के रूप में use नहीं करनी चाहिए। Security-sensitive identifier के लिए UUID v4 use करें।
Code Examples
UUID v3 के लिए namespace UUID और name string required हैं। Standard uuid package use करें:
// Browser / Node.js — UUID v3 without dependencies
function uuidV3(namespace, name) {
// namespace must be a UUID string like '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
const nsBytes = namespace.replace(/-/g, '').match(/../g).map(h => parseInt(h, 16))
const nameBytes = [...new TextEncoder().encode(name)]
const combined = new Uint8Array([...nsBytes, ...nameBytes])
// md5(combined) — use your preferred MD5 library or the inline implementation
const hash = md5(combined) // returns Uint8Array(16)
hash[6] = (hash[6] & 0x0f) | 0x30 // version 3
hash[8] = (hash[8] & 0x3f) | 0x80 // variant
const h = [...hash].map(b => b.toString(16).padStart(2, '0')).join('')
return `${h.slice(0,8)}-${h.slice(8,12)}-${h.slice(12,16)}-${h.slice(16,20)}-${h.slice(20)}`
}
// Using the 'uuid' npm package
import { v3 as uuidv3 } from 'uuid'
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
console.log(uuidv3('example.com', uuidv3.DNS))
// → '9073926b-929f-31c2-abc9-fad77ae3e8eb' (always the same)import uuid
# Using the standard library
dns_uuid = uuid.uuid3(uuid.NAMESPACE_DNS, 'example.com')
print(dns_uuid)
# → 9073926b-929f-31c2-abc9-fad77ae3e8eb
url_uuid = uuid.uuid3(uuid.NAMESPACE_URL, 'https://example.com/page')
print(url_uuid)
# Custom namespace
MY_NS = uuid.UUID('a1b2c3d4-e5f6-7890-abcd-ef1234567890')
custom = uuid.uuid3(MY_NS, 'my-entity-name')
print(custom)package main
import (
"fmt"
"github.com/google/uuid"
)
func main() {
// Standard DNS namespace
ns := uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
id := uuid.NewMD5(ns, []byte("example.com"))
fmt.Println(id)
// → 9073926b-929f-31c2-abc9-fad77ae3e8eb
// URL namespace
urlNS := uuid.MustParse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
idURL := uuid.NewMD5(urlNS, []byte("https://example.com/page"))
fmt.Println(idURL)
}