UUID v2 Generator

लोकल डोमेन और ID के साथ DCE Security UUID v2 जनरेट करें

UUID बनाने के लिए जनरेट पर क्लिक करें
नोट:UUID v2 लोकल डोमेन और ID को UUID संरचना में एन्कोड करता है
Note:UUID v2 एक legacy format है जो DCE Security contexts के लिए define किया गया है। Modern applications में इसकी rarely ज़रूरत होती है। General-purpose unique IDs के लिए, UUID v4 recommended है।

UUID v2 क्या है?

UUID v2 DCE Security UUID version है, Distributed Computing Environment (DCE) specification के हिस्से के रूप में standardised और RFC 4122 में referenced। यह UUID v1 को POSIX user या group identifier (UID/GID) को timestamp field में embed करके extend करता है।

Structure UUID v1 के समान है, लेकिन 32-bit time_low field को 32-bit local identifier (जैसे POSIX UID) से replace किया गया है और एक 1-byte local_domain field identify करता है कि यह किस प्रकार का local ID है।

UUID v2 modern software में extremely rare है। ज़्यादातर developers को कभी एक generate करने की ज़रूरत नहीं पड़ेगी। यह page format को document करती है completeness के लिए और legacy systems में encountered UUID v2 values decode करने में aid के लिए।

UUID v2 Structure

UUID v2 का same 128-bit, hyphenated format है। Fields UUID v1 से निम्नानुसार differ करते हैं:

FieldBitsPurpose
local_id32<code>local_id</code> — 32-bit local domain identifier (जैसे <code>/etc/passwd</code> से POSIX UID), UUID v1 का time_low field replace करता है
time_mid16<code>time_mid</code> — truncated UUID v1 timestamp के middle 16 bits
time_hi+version16<code>time_hi_and_version</code> — version nibble <code>2</code> set के साथ top 12 timestamp bits
variant+clock_hi8<code>clock_seq_hi_and_reserved</code> — variant bits plus clock sequence का high portion
local_domain8<code>local_domain</code> — domain identifier: <code>0</code> = POSIX User (UID), <code>1</code> = POSIX Group (GID), <code>2</code> = Organization
node48<code>node</code> — generating host का 48-bit MAC address

Example: 000003e8-92e0-21ef-8000-325096b39f47 — local_id 0x000003e8 = UID 1000, local_domain 0x00 = POSIX User

Note:local_id field UUID v1 के time_low field को replace करता है, UUID v2 में timestamp केवल 28 bits wide है (UUID v1 के 60 bits की तुलना में)। यह timestamp precision को approximately 7.2 minutes तक reduce करता है।

Local Domain Values

local_domain byte UUID में embedded local identifier का type specify करता है:

0POSIX_UID
POSIX User ID — <code>/etc/passwd</code> से numeric UID, <code>os.getuid()</code> के माध्यम से obtainable
1POSIX_GID
POSIX Group ID — <code>/etc/group</code> से numeric GID, <code>os.getgid()</code> के माध्यम से obtainable
2ORG
Organization — custom 32-bit organizational identifier; semantics application-defined हैं

Domain values DCE specification द्वारा defined हैं। Values 3–255 reserved हैं। Practice में, केवल domain 0 (Person/UID) real-world UUID v2 values में commonly encountered है।

UUID v2 Rarely क्यों Use किया जाता है

तीन characteristics UUID v2 को ज़्यादातर modern applications के लिए impractical बनाते हैं:

Coarse Timestamp Resolution

Timestamp 28 bits तक truncated है (approximately 7.2-minute granularity)। उस window में, same local_id और domain के साथ same host पर generate किए गए UUIDs unique नहीं हैं।

No Standard Library Support

UUID v1 और v4 के विपरीत, UUID v2 ज़्यादातर UUID libraries द्वारा supported नहीं है। uuid npm package, Python's uuid module, और Java's java.util.UUID सभी v2 omit करते हैं।

POSIX-specific Semantics

Local domain concept (UID/GID) inherently POSIX-specific है और Windows, embedded systems, या cloud environments में meaningfully translate नहीं होता।

Warning:नए projects के लिए UUID v2 use न करें। यदि आपको legacy system में UUID v2 मिला है, तो इस tool का use इसके fields decode करने के लिए करें। नए development के लिए, UUID v4 use करें।

Historical Context

UUID v2 को Open Software Foundation के Distributed Computing Environment (DCE/RPC) के हिस्से के रूप में 1990s के early में define किया गया था।

DCE security model एक homogeneous POSIX environment assume करता था जहाँ हर node shared UID/GID namespace में participate करता था।

  • Internet ने homogeneous POSIX environments से heterogeneous cloud architectures की ओर move किया
  • Modern authentication identifiers में embedded UIDs के बजाय tokens (JWT, OAuth) use करती है
  • UUID v4 (fully random) और UUID v7 (time-ordered) unique identifiers के practical use cases cover करते हैं
  • DCE/RPC itself widespread use से बाहर हो गया

RFC 4122 (2005) ने UUID v2 को DCE specification के reference द्वारा include किया, लेकिन detailed generation algorithm deliberately omit किया।

RFC 9562 (2024) ने UUID v2 को historical completeness के लिए retain किया।

UUID v2 vs UUID v1

UUID v2 UUID v1 से derived है। यहाँ वे कैसे compare करते हैं:

AspectUUID v1UUID v2
Timestamp bits60 bits (~100ns precision)28 bits (~7.2-minute precision)
Local identifierकोई नहीं32-bit POSIX UID/GID
Local domainPresent नहीं0=UID, 1=GID, 2=Org
Node fieldMAC addressMAC address
Library supportWidely supportedRarely supported
StandardRFC 4122 / RFC 9562DCE spec (RFC 4122 द्वारा referenced)
Practical useLegacy timestamp-ordered IDs (Cassandra)केवल DCE Security contexts

UUID v2 general-purpose use के लिए UUID v1 पर कुछ offer नहीं करता, और ज़्यादातर respects में strictly worse है। नए development के लिए UUID v2 choose करने का कोई reason नहीं है।

Code Examples

UUID v2 का standard libraries में कोई native support नहीं है। निम्नलिखित examples UUID v2 values के साथ काम करने का तरीका दिखाते हैं:

Python — manual implementation

Python
import uuid, struct, time

def uuid_v2(local_id: int, local_domain: int = 0) -> str:
    """
    Generate a DCE Security UUID (v2).
    local_domain: 0 = POSIX UID, 1 = POSIX GID, 2 = Org
    local_id: 32-bit unsigned integer (e.g. os.getuid())
    """
    # Get a v1 UUID for the time and node fields
    v1 = uuid.uuid1()
    fields = list(v1.fields)  # [time_low, time_mid, time_hi_version, clock_seq_hi_variant, clock_seq_low, node]

    # Replace time_low with local_id
    fields[0] = local_id & 0xFFFFFFFF

    # Replace version nibble: clear lower 12 bits of time_hi, set version 2
    fields[2] = (fields[2] & 0x0FFF) | 0x2000

    # Replace clock_seq_low with local_domain
    fields[4] = local_domain & 0xFF

    return str(uuid.UUID(fields=tuple(fields)))


import os
print(uuid_v2(os.getuid(), local_domain=0))   # POSIX UID
print(uuid_v2(os.getgid(), local_domain=1))   # POSIX GID

Go — note

Go
// The standard "github.com/google/uuid" package does NOT support v2.
// You would need to implement it manually, similar to the Python example above.
// Most Go developers use v4 or v7 for new projects.
import "github.com/google/uuid"

v4 := uuid.New()          // v4 — recommended for most use cases
v7, _ := uuid.NewV7()     // v7 — time-ordered, ideal for database primary keys

JavaScript — extract fields

Existing UUID v2 string से local_id और domain extract करने के लिए:

JavaScript
// Extracting fields from a UUID v2 string
const uuidStr = '000003e8-1234-2abc-8200-a1b2c3d4e5f6'
//               ^^^^^^^^ ^^^^ ^    ^^
//               local_id      ver  variant+clockSeqHi
//                                  ^^ = local_domain (00 = POSIX UID)

const parts = uuidStr.split('-')

const localId     = parseInt(parts[0], 16)       // → 1000 (0x3e8)
const version     = parseInt(parts[2][0], 16)    // → 2
const localDomain = parseInt(parts[3].slice(2), 16) // low byte of octet pair

const DOMAIN_NAMES = ['POSIX UID', 'POSIX GID', 'Org']
console.log(`Local ID: ${localId}`)                       // Local ID: 1000
console.log(`Version:  ${version}`)                       // Version:  2
console.log(`Domain:   ${DOMAIN_NAMES[localDomain]}`)     // Domain:   POSIX UID
Note:google/uuid Go package UUID v2 generation support करता है uuid.NewDCEGroup() और uuid.NewDCEPerson() के माध्यम से।

अक्सर पूछे जाने वाले प्रश्न

क्या मैं JavaScript में UUID v2 generate कर सकता हूँ?
कोई standard library JavaScript में UUID v2 generation support नहीं करती। आपको bytes manually construct करने होंगे।
local_id field में क्या होता है?
local_id एक 32-bit unsigned integer है जिसका meaning local_domain byte पर depend करता है। Domain 0 के लिए, यह process run करने वाले user का POSIX UID है।
क्या UUID v2 में timestamp reliable है?
केवल coarse indicator के रूप में। 60-bit UUID v1 timestamp के केवल 28 bits retain होने के कारण, effective precision approximately 7.2 minutes है।
कौन से systems अभी भी UUID v2 use करते हैं?
UUID v2 primarily 1990s के legacy DCE/RPC systems में encountered है। Modern systems लगभग universally UUID v4 या v7 use करते हैं।
RFC 4122 UUID v2 algorithm include क्यों नहीं करता?
RFC 4122 explicitly state करता है कि UUID v2 generation algorithm DCE specification द्वारा defined है, IETF द्वारा नहीं।
क्या UUID v2 GUID के समान है?
नहीं। GUID Microsoft का UUID standard का implementation है। Microsoft COM UUID v1 और v4 GUIDs internally use करता है। UUID v2 Windows GUID infrastructure द्वारा use नहीं किया जाता।