Guid microsoft

Guid microsoft DEFAULT

Guid Struct



Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents a globally unique identifier (GUID).






The following example uses the System.Runtime.InteropServices.GuidAttribute class to assign a GUID to an interface and to a user-defined class. It retrieves the value of the GUID by calling the GetCustomAttribute method, and compares it with two other GUIDs to determine whether they are equal.

Note that the GuidAttribute attribute is typically used in an application to expose a type to COM. If you compile this example, you can run the Assembly Registration tool (Regasm.exe) on the generated assembly to create registry (.reg) and type library (.tlb) files. The .reg file can be used to register the coclass in the registry, and the .tlb file can provide metadata for COM interop.

A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated.



Initializes a new instance of the Guid structure by using the specified array of bytes.

Guid(Int32, Int16, Int16, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)

Initializes a new instance of the Guid structure by using the specified integers and bytes.

Guid(Int32, Int16, Int16, Byte[])

Initializes a new instance of the Guid structure by using the specified integers and byte array.


Initializes a new instance of the Guid structure by using the value represented by the specified read-only span of bytes.


Initializes a new instance of the Guid structure by using the value represented by the specified string.

Guid(UInt32, UInt16, UInt16, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)

Initializes a new instance of the Guid structure by using the specified unsigned integers and bytes.



A read-only instance of the Guid structure whose value is all zeros.



Compares this instance to a specified Guid object and returns an indication of their relative values.


Compares this instance to a specified object and returns an indication of their relative values.


Returns a value indicating whether this instance and a specified Guid object represent the same value.


Returns a value that indicates whether this instance is equal to a specified object.


Returns the hash code for this instance.


Initializes a new instance of the Guid structure.


Converts a read-only character span that represents a GUID to the equivalent Guid structure.


Converts the string representation of a GUID to the equivalent Guid structure.

ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Converts the character span representation of a GUID to the equivalent Guid structure, provided that the string is in the specified format.

ParseExact(String, String)

Converts the string representation of a GUID to the equivalent Guid structure, provided that the string is in the specified format.


Returns a 16-element byte array that contains the value of this instance.


Returns a string representation of the value of this instance in registry format.


Returns a string representation of the value of this Guid instance, according to the provided format specifier.

ToString(String, IFormatProvider)

Returns a string representation of the value of this instance of the Guid class, according to the provided format specifier and culture-specific format information.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>)

Tries to format the current GUID instance into the provided character span.

TryParse(ReadOnlySpan<Char>, Guid)

Converts the specified read-only span of characters containing the representation of a GUID to the equivalent Guid structure.

TryParse(String, Guid)

Converts the string representation of a GUID to the equivalent Guid structure.

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Guid)

Converts span of characters representing the GUID to the equivalent Guid structure, provided that the string is in the specified format.

TryParseExact(String, String, Guid)

Converts the string representation of a GUID to the equivalent Guid structure, provided that the string is in the specified format.


Tries to write the current GUID instance into a span of bytes.


Explicit Interface Implementations

Applies to


Guid class

This class represents a globally unique identifier, as described by IETF RFC 4122.

The input string is normalized and validated, which provides important guarantees that simplify other code that works with the GUID. This class also provides basic support for generating a pseudo-random GUID; however, be aware that the uniqueness depends on the browser's function and may be not be suitable for some applications.

See RFC4122 for more information.



Returns a new empty Guid instance.



Compare this instance to another Guid instance


Indicates whether a GUID is valid, i.e. whether it would be successfully parsed by . This function is cheaper than because it does not construct a Guid object.


Returns a new Guid instance with a pseudo-randomly generated GUID, according to the version 4 UUID algorithm from RFC 4122.


Parses the input string to construct a new Guid object. If the string cannot be parsed, then an error is thrown.


Returns a string representation of the GUID


Attempts to parse the input string to construct a new Guid object. If the string cannot be parsed, then undefined is returned.

Property Details


Returns a new empty Guid instance.

Property Value


Method Details


Compare this instance to another Guid instance




True if this instance and the specified Guid object represent the same value.


Indicates whether a GUID is valid, i.e. whether it would be successfully parsed by . This function is cheaper than because it does not construct a Guid object.



string | undefined | null

The input string.


true, if the Guid is valid.


Returns a new Guid instance with a pseudo-randomly generated GUID, according to the version 4 UUID algorithm from RFC 4122.




A new unique Guid object


Parses the input string to construct a new Guid object. If the string cannot be parsed, then an error is thrown.



string | undefined | null



A valid Guid object


Example syntaxes accepted by this function:


Returns a string representation of the GUID


The GUID value in lowercase hexadecimal without braces.



Attempts to parse the input string to construct a new Guid object. If the string cannot be parsed, then undefined is returned.



string | undefined | null

The input string.


@microsoft/sp-core-library!default:class | undefined

The Guid object, or undefined if the string could not be parsed.


Example syntaxes accepted by this function:

  1. Cumbias 2015
  2. Skullcandy ear muffs
  3. Android notification led
  4. Ultraman ginga theme

GUID structure (guiddef.h)

  • 2 minutes to read

A GUID identifies an object such as a COM interfaces, or a COM class object, or a manager entry-point vector (EPV). A GUID is a 128-bit value consisting of one group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal digits each, followed by one group of 12 hexadecimal digits. The following example GUID shows the groupings of hexadecimal digits in a GUID: 6B29FC40-CA47-1067-B31D-00DD010662DA.

The GUID structure stores a GUID.



Specifies the first 8 hexadecimal digits of the GUID.

Specifies the first group of 4 hexadecimal digits.

Specifies the second group of 4 hexadecimal digits.

Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. The remaining 6 bytes contain the final 12 hexadecimal digits.

GUIDs are the Microsoft implementation of the distributed computing environment (DCE) universally unique identifier (UUID). The RPC run-time libraries use UUIDs to check for compatibility between clients and servers and to select among multiple implementations of an interface. The Windows access-control functions use GUIDs to identify the type of object that an object-specific ACE in an access-control list (ACL) protects.

See also



Microsoft Azure Data Scientist Certification (DP-100): Train machine learning models at scale

Guid.NewGuid Method

Initializes a new instance of the Guid structure.



A new GUID object.


The following code example creates and displays the values of two Guid objects.


This is a convenient method that you can call to get a new Guid. The method creates a Version 4 Universally Unique Identifier (UUID) as described in RFC 4122, Sec. 4.4. The returned Guid is guaranteed to not equal Guid.Empty.

On Windows, this function wraps a call to the CoCreateGuid function. The generated GUID contains 122 bits of strong entropy.

On non-Windows platforms, starting with .NET 6, this function calls the OS's underlying cryptographically secure pseudo-random number generator (CSPRNG) to generate 122 bits of strong entropy. In previous versions of .NET, the entropy is not guaranteed to be generated by a CSPRNG.

It is recommended that applications not use the NewGuid method for cryptographic purposes. First, since a Version 4 UUID has a partially predictable bit pattern, the NewGuid function cannot serve as a proper cryptographic pseudo-random function (PRF). If the output of NewGuid is given to a cryptographic component which requires its input to be generated by a proper PRF, the cryptographic component may not be able to maintain its security properties. Second, NewGuid utilizes at most 122 bits of entropy, regardless of platform. Some cryptographic components set a minimum entropy level on their inputs as a matter of policy. Such policies often set the minimum entropy level at 128 bits or higher. Passing the output of NewGuid to such a routine may violate its policy.

If an application requires random data for cryptographic purposes, consider using a static method on the RandomNumberGenerator class. That class provides a random number generator suitable for cryptographic use.

Applies to


Microsoft guid

// ==++==//// Copyright (c) Microsoft Corporation. All rights reserved.//// ==--==namespaceSystem {usingSystem;usingSystem.Globalization;usingSystem.Text;usingMicrosoft.Win32;usingSystem.Runtime.InteropServices;usingSystem.Runtime.CompilerServices;usingSystem.Diagnostics.Contracts;// Represents a Globally Unique Identifier. [StructLayout(LayoutKind.Sequential)] [Serializable][System.Runtime.InteropServices.ComVisible(true)] [System.Runtime.Versioning.NonVersionable] // This only applies to field layoutpublicstructGuid : IFormattable, IComparable#ifGENERICS_WORK , IComparable<Guid>, IEquatable<Guid>#endif {publicstaticreadonlyGuidEmpty=newGuid();////////////////////////////////////////////////////////////////////////////////// Member variables////////////////////////////////////////////////////////////////////////////////privateint_a;privateshort_b;privateshort_c;privatebyte_d;privatebyte_e;privatebyte_f;privatebyte_g;privatebyte_h;privatebyte_i;privatebyte_j;privatebyte_k;////////////////////////////////////////////////////////////////////////////////// Constructors////////////////////////////////////////////////////////////////////////////////// Creates a new guid from an array of bytes.//publicGuid(byte[] b) {if (b==null)thrownewArgumentNullException("b");if (b.Length!=16)thrownewArgumentException(Environment.GetResourceString("Arg_GuidArrayCtor", "16"));Contract.EndContractBlock();_a= ((int)b[3] <<24) | ((int)b[2] <<16) | ((int)b[1] <<8) |b[0];_b= (short)(((int)b[5] <<8) |b[4]);_c= (short)(((int)b[7] <<8) |b[6]);_d=b[8];_e=b[9];_f=b[10];_g=b[11];_h=b[12];_i=b[13];_j=b[14];_k=b[15]; } [CLSCompliant(false)]publicGuid (uinta, ushortb, ushortc, byted, bytee, bytef, byteg, byteh, bytei, bytej, bytek) {_a= (int)a;_b= (short)b;_c= (short)c;_d=d;_e=e;_f=f;_g=g;_h=h;_i=i;_j=j;_k=k; }// Creates a new GUID initialized to the value represented by the arguments.//publicGuid(inta, shortb, shortc, byte[] d) {if (d==null)thrownewArgumentNullException("d");// Check that array is not too bigif(d.Length!=8)thrownewArgumentException(Environment.GetResourceString("Arg_GuidArrayCtor", "8"));Contract.EndContractBlock();_a=a;_b=b;_c=c;_d=d[0];_e=d[1];_f=d[2];_g=d[3];_h=d[4];_i=d[5];_j=d[6];_k=d[7]; }// Creates a new GUID initialized to the value represented by the// arguments. The bytes are specified like this to avoid endianness issues.//publicGuid(inta, shortb, shortc, byted, bytee, bytef, byteg, byteh, bytei, bytej, bytek) {_a=a;_b=b;_c=c;_d=d;_e=e;_f=f;_g=g;_h=h;_i=i;_j=j;_k=k; } [Flags]privateenumGuidStyles {None=0x00000000, AllowParenthesis=0x00000001, //Allow the guid to be enclosed in parensAllowBraces=0x00000002, //Allow the guid to be enclosed in bracesAllowDashes=0x00000004, //Allow the guid to contain dash group separatorsAllowHexPrefix=0x00000008, //Allow the guid to contain {0xdd,0xdd}RequireParenthesis=0x00000010, //Require the guid to be enclosed in parensRequireBraces=0x00000020, //Require the guid to be enclosed in bracesRequireDashes=0x00000040, //Require the guid to contain dash group separatorsRequireHexPrefix=0x00000080, //Require the guid to contain {0xdd,0xdd}HexFormat=RequireBraces|RequireHexPrefix, /* X */NumberFormat=None, /* N */DigitFormat=RequireDashes, /* D */BraceFormat=RequireBraces|RequireDashes, /* B */ParenthesisFormat=RequireParenthesis|RequireDashes, /* P */Any=AllowParenthesis|AllowBraces|AllowDashes|AllowHexPrefix, }privateenumGuidParseThrowStyle {None=0,All=1,AllButOverflow=2 }privateenumParseFailureKind {None=0,ArgumentNull=1,Format=2,FormatWithParameter=3,NativeException=4,FormatWithInnerException=5 }// This will store the result of the parsing. And it will eventually be used to construct a Guid instance.privatestructGuidResult {internalGuidparsedGuid;internalGuidParseThrowStylethrowStyle;internalParseFailureKindm_failure;internalstringm_failureMessageID;internalobjectm_failureMessageFormatArgument;internalstringm_failureArgumentName;internalExceptionm_innerException;internalvoidInit(GuidParseThrowStylecanThrow) {parsedGuid=Guid.Empty;throwStyle=canThrow; }internalvoidSetFailure(ExceptionnativeException) {m_failure=ParseFailureKind.NativeException;m_innerException=nativeException; }internalvoidSetFailure(ParseFailureKindfailure, stringfailureMessageID) {SetFailure(failure, failureMessageID, null, null, null); }internalvoidSetFailure(ParseFailureKindfailure, stringfailureMessageID, objectfailureMessageFormatArgument) {SetFailure(failure, failureMessageID, failureMessageFormatArgument, null, null); }internalvoidSetFailure(ParseFailureKindfailure, stringfailureMessageID, objectfailureMessageFormatArgument,stringfailureArgumentName, ExceptioninnerException) {Contract.Assert(failure!=ParseFailureKind.NativeException, "ParseFailureKind.NativeException should not be used with this overload");m_failure=failure;m_failureMessageID=failureMessageID;m_failureMessageFormatArgument=failureMessageFormatArgument;m_failureArgumentName=failureArgumentName;m_innerException=innerException;if (throwStyle!=GuidParseThrowStyle.None) {throwGetGuidParseException(); } }internalExceptionGetGuidParseException() {switch (m_failure) {caseParseFailureKind.ArgumentNull:returnnewArgumentNullException(m_failureArgumentName, Environment.GetResourceString(m_failureMessageID));caseParseFailureKind.FormatWithInnerException:returnnewFormatException(Environment.GetResourceString(m_failureMessageID), m_innerException);caseParseFailureKind.FormatWithParameter:returnnewFormatException(Environment.GetResourceString(m_failureMessageID, m_failureMessageFormatArgument));caseParseFailureKind.Format:returnnewFormatException(Environment.GetResourceString(m_failureMessageID));caseParseFailureKind.NativeException:returnm_innerException;default:Contract.Assert(false, "Unknown GuidParseFailure: "+m_failure);returnnewFormatException(Environment.GetResourceString("Format_GuidUnrecognized")); } } }// Creates a new guid based on the value in the string. The value is made up// of hex digits speared by the dash ("-"). The string may begin and end with// brackets ("{", "}").//// The string must be of the form dddddddd-dddd-dddd-dddd-dddddddddddd. where// d is a hex digit. (That is 8 hex digits, followed by 4, then 4, then 4,// then 12) such as: "CA761232-ED42-11CE-BACD-00AA0057B223"//publicGuid(Stringg) {if (g==null) {thrownewArgumentNullException("g"); }Contract.EndContractBlock();this=Guid.Empty;GuidResultresult=newGuidResult();result.Init(GuidParseThrowStyle.All);if (TryParseGuid(g
How to use Microsoft OneDrive

Universally unique identifier

128-bit label used to identify information in computer systems

UUID/GUID as used by UEFIvariables

A universally unique identifier (UUID) is a 128-bitlabel used for information in computer systems. The term globally unique identifier (GUID) is also used, often in software created by Microsoft.[1]

When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration authority or coordination between the parties generating them, unlike most other numbering schemes. While the probability that a UUID will be duplicated is not zero, it is close enough to zero to be negligible.[2][3]

Thus, anyone can create a UUID and use it to identify something with near certainty that the identifier does not duplicate one that has already been, or will be, created to identify something else. Information labeled with UUIDs by independent parties can therefore be later combined into a single database or transmitted on the same channel, with a negligible probability of duplication.

Adoption of UUIDs is widespread, with many computing platforms providing support for generating them and for parsing their textual representation.


In the 1980s Apollo Computer originally used UUIDs in the Network Computing System (NCS) and later in the Open Software Foundation's (OSF) Distributed Computing Environment (DCE). The initial design of DCE UUIDs was based on the NCS UUIDs,[4] whose design was in turn inspired by the (64-bit) unique identifiers defined and used pervasively in Domain/OS, an operating system designed by Apollo Computer. Later,[when?] the Microsoft Windows platforms adopted the DCE design as "globally unique identifiers" (GUIDs). RFC 4122 registered a URN namespace for UUIDs[1] and recapitulated the earlier specifications, with the same technical content.[citation needed] When in July 2005 RFC 4122 was published as a proposed IETF standard, the ITU had also standardized UUIDs, based on the previous standards and early versions of RFC 4122.[citation needed]


UUIDs are standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).[5][6]

UUIDs are documented as part of ISO/IEC 11578:1996 "Information technology – Open Systems Interconnection – Remote Procedure Call (RPC)" and more recently in ITU-T Rec. X.667 | ISO/IEC 9834-8:2005.[7]

The Internet Engineering Task Force (IETF) published the Standards-Track RFC 4122,[1] technically equivalent to ITU-T Rec. X.667 | ISO/IEC 9834-8.


In its canonical textual representation, the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4 hyphens). For example:

The four-bit M and the 1 to 3 bit fields code the format of the UUID itself.

The four bits of digit are the UUID version, and the 1 to 3 most significant bits of digit code the UUID variant. (See below.) In the example, M is , and N is (10xx2), meaning that this is a version-1, variant-1 UUID; that is, a time-based DCE/RFC 4122 UUID.

The canonical 8-4-4-4-12 format string is based on the record layout for the 16 bytes of the UUID:[1]

Name Length (bytes) Length (hex digits) Length (bits) Contents
time_low 4 8 32 integer giving the low 32 bits of the time
time_mid 2 4 16 integer giving the middle 16 bits of the time
time_hi_and_version 2 4 16 4-bit "version" in the most significant bits, followed by the high 12 bits of the time
clock_seq_hi_and_res clock_seq_low 2 4 16 1 to 3-bit "variant" in the most significant bits, followed by the 13 to 15-bit clock sequence
node 6 12 48 the 48-bit node id

These fields correspond to those in version 1 and 2 UUIDs (that is, time-based UUIDs), but the same 8-4-4-4-12 representation is used for all UUIDs, even for UUIDs constructed differently.

RFC 4122 Section 3 requires that the characters be generated in lower case, while being case-insensitive on input.

Microsoft GUIDs are sometimes represented with surrounding braces:

This format should not be confused with "Windows Registry format", which refers to the format within the curly braces.[8]

RFC 4122 defines a Uniform Resource Name (URN) namespace for UUIDs. A UUID presented as a URN appears as follows:[1]


The binary encoding of UUIDs varies between systems. Variant 1 UUIDs, nowadays the most common variant, are encoded in a big-endian format. For example, is encoded as the bytes .[9][10]

Variant 2 UUIDs, historically used in Microsoft's COM/OLE libraries, use a mixed-endian format, whereby the first three components of the UUID are little-endian, and the last two are big-endian. For example, is encoded as the bytes .[11][12]


The "variant" field of UUIDs, or the N position indicate their format and encoding. RFC 4122 defines four variants of lengths 1 to 3 bits:

  • Variant 0 (indicated by the one-bit pattern 0xxx2, N = ) is for backwards compatibility with the now-obsolete Apollo Network Computing System 1.5 UUID format developed around 1988. The first 6 octets of the UUID are a 48-bit timestamp (the number of 4-microsecond units of time since 1 January 1980 UTC); the next 2 octets are reserved; the next octet is the "address family"; and the final 7 octets are a 56-bit host ID in the form specified by the address family. Though different in detail, the similarity with modern version-1 UUIDs is evident. The variant bits in the current UUID specification coincide with the high bits of the address family octet in NCS UUIDs. Though the address family could hold values in the range 0..255, only the values 0..13 were ever defined. Accordingly, the variant-0 bit pattern avoids conflicts with historical NCS UUIDs, should any still exist in databases.[13]
  • Variant 1 (10xx2, N = , 2 bits) are referred to as RFC 4122/DCE 1.1 UUIDs, or "Leach–Salz" UUIDs, after the authors of the original Internet Draft.
  • Variant 2 (110x2,  = , 3 bits) is characterized in the RFC as "reserved, Microsoft Corporation backward compatibility" and was used for early GUIDs on the Microsoft Windows platform. It differs from variant 1 only by the endianness in binary storage or transmission: variant-1 UUIDs use "network" (big-endian) byte order, while variant-2 GUIDs use "native" (little-endian) byte order for some subfields of the UUID.
  • Reserved is defined as the 3-bit variant bit pattern 111x2 (N = ).

Variants 1 and 2 are used by the current UUID specification. In their textual representations, variants 1 and 2 are the same, except for the variant bits. In the binary representation, there is an endianness difference.[1] When byte swapping is required to convert between the big-endian byte order of variant 1 and the little-endian byte order of variant 2, the fields above define the swapping. The first three fields are unsigned 32- and 16-bit integers and are subject to swapping, while the last two fields consist of uninterpreted bytes, not subject to swapping. This byte swapping applies even for versions 3, 4, and 5, where the canonical fields do not correspond to the content of the UUID.[1]

While some important GUIDs, such as the identifier for the Component Object ModelIUnknown interface, are nominally variant-2 UUIDs, many identifiers generated and used in Microsoft Windows software and referred to as "GUIDs" are standard variant-1 RFC 4122/DCE 1.1 network-byte-order UUIDs, rather than little-endian variant-2 UUIDs. The current version of the Microsoft tool produces standard variant-1 UUIDs. Some Microsoft documentation states that "GUID" is a synonym for "UUID",[14] as standardized in RFC 4122. RFC 4122 itself states that UUIDs "are also known as GUIDs". All this suggests that "GUID", while originally referring to a variant of UUID used by Microsoft, has become simply an alternative name for UUID, with both variant-1 and variant-2 GUIDs being extant.


For both variants 1 and 2, five "versions" are defined in the standards, and each version may be more appropriate than the others in specific use cases. Version is indicated by the in the string representation.

Version-1 UUIDs are generated from a time and a node ID (usually the MAC address); version-2 UUIDs are generated from an identifier (usually a group or user ID), time, and a node ID; versions 3 and 5 produce deterministic UUIDs generated by hashing a namespace identifier and name; and version-4 UUIDs are generated using a random or pseudo-random number.

Nil UUID[edit]

The "nil" UUID, a special case, is the UUID ; that is, all bits set to zero.[1]

Version 1 (date-time and MAC address)[edit]

Version 1 concatenates the 48-bit MAC address of the "node" (that is, the computer generating the UUID), with a 60-bit timestamp, being the number of 100-nanosecond intervals since midnight 15 October 1582 Coordinated Universal Time (UTC), the date on which the Gregorian calendar was first adopted. RFC 4122 states that the time value rolls over around 3400 AD,[1]: 3  depending on the algorithm used, which implies that the 60-bit timestamp is a signed quantity. However some software, such as the libuuid library, treats the timestamp as unsigned, putting the rollover time in 5236 AD.[15] The rollover time as defined by ITU-T Rec. X.667 is 3603 AD.[16]: v 

A 13-bit or 14-bit "uniquifying" clock sequence extends the timestamp in order to handle cases where the processor clock does not advance fast enough, or where there are multiple processors and UUID generators per node. When UUIDs are generated faster than the system clock could advance, the lower bits of the timestamp fields can be generated by incrementing it every time a UUID is being generated, to simulate a high-resolution timestamp. With each version 1 UUID corresponding to a single point in space (the node) and time (intervals and clock sequence), the chance of two properly generated version-1 UUIDs being unintentionally the same is practically nil. Since the time and clock sequence total 74 bits, 274 (1.8×1022, or 18 sextillion) version-1 UUIDs can be generated per node ID, at a maximal average rate of 163 billion per second per node ID.[1]

In contrast to other UUID versions, version-1 and -2 UUIDs based on MAC addresses from network cards rely for their uniqueness in part on an identifier issued by a central registration authority, namely the Organizationally Unique Identifier (OUI) part of the MAC address, which is issued by the IEEE to manufacturers of networking equipment.[17] The uniqueness of version-1 and version-2 UUIDs based on network-card MAC addresses also depends on network-card manufacturers properly assigning unique MAC addresses to their cards, which like other manufacturing processes is subject to error. Additionally some operating system permit the end user to customise the MAC address, notably OpenWRT.[18]

Usage of the node's network card MAC address for the node ID means that a version-1 UUID can be tracked back to the computer that created it. Documents can sometimes be traced to the computers where they were created or edited through UUIDs embedded into them by word processing software. This privacy hole was used when locating the creator of the Melissa virus.[19]

RFC 4122 does allow the MAC address in a version-1 (or 2) UUID to be replaced by a random 48-bit node ID, either because the node does not have a MAC address, or because it is not desirable to expose it. In that case, the RFC requires that the least significant bit of the first octet of the node ID should be set to 1.[1] This corresponds to the multicast bit in MAC addresses, and setting it serves to differentiate UUIDs where the node ID is randomly generated from UUIDs based on MAC addresses from network cards, which typically have unicast MAC addresses.[1]

Version 2 (date-time and MAC address, DCE security version)[edit]

RFC 4122 reserves version 2 for "DCE security" UUIDs; but it does not provide any details. For this reason, many UUID implementations omit version 2. However, the specification of version-2 UUIDs is provided by the DCE 1.1 Authentication and Security Services specification.[6]

Version-2 UUIDs are similar to version 1, except that the least significant 8 bits of the clock sequence are replaced by a "local domain" number, and the least significant 32 bits of the timestamp are replaced by an integer identifier meaningful within the specified local domain. On POSIX systems, local-domain numbers 0 and 1 are for user ids (UIDs) and group ids (GIDs) respectively, and other local-domain numbers are site-defined.[6] On non-POSIX systems, all local domain numbers are site-defined.

The ability to include a 40-bit domain/identifier in the UUID comes with a tradeoff. On the one hand, 40 bits allow about 1 trillion domain/identifier values per node ID. On the other hand, with the clock value truncated to the 28 most significant bits, compared to 60 bits in version 1, the clock in a version 2 UUID will "tick" only once every 429.49 seconds, a little more than 7 minutes, as opposed to every 100 nanoseconds for version 1. And with a clock sequence of only 6 bits, compared to 14 bits in version 1, only 64 unique UUIDs per node/domain/identifier can be generated per 7-minute clock tick, compared to 16,384 clock sequence values for version 1.[20] Thus, Version 2 may not be suitable for cases where UUIDs are required, per node/domain/identifier, at a rate exceeding about one every seven minutes.

Versions 3 and 5 (namespace name-based)[edit]

Version-3 and version-5 UUIDs are generated by hashing a namespace identifier and name. Version 3 uses MD5 as the hashing algorithm, and version 5 uses SHA-1.[1]

The namespace identifier is itself a UUID. The specification provides UUIDs to represent the namespaces for URLs, fully qualified domain names, object identifiers, and X.500distinguished names; but any desired UUID may be used as a namespace designator.

To determine the version-3 UUID corresponding to a given namespace and name, the UUID of the namespace is transformed to a string of bytes, concatenated with the input name, then hashed with MD5, yielding 128 bits. Then 6 or 7 bits are replaced by fixed values, the 4-bit version (e.g. 00112 for version 3), and the 2- or 3-bit UUID "variant" (e.g. 102 indicating a RFC 4122 UUIDs, or 1102 indicating a legacy Microsoft GUID). Since 6 or 7 bits are thus predetermined, only 121 or 122 bits contribute to the uniqueness of the UUID.

Version-5 UUIDs are similar, but SHA-1 is used instead of MD5. Since SHA-1 generates 160-bit digests, the digest is truncated to 128 bits before the version and variant bits are replaced.

Version-3 and version-5 UUIDs have the property that the same namespace and name will map to the same UUID. However, neither the namespace nor name can be determined from the UUID, even if one of them is specified, except by brute-force search. RFC 4122 recommends version 5 (SHA-1) over version 3 (MD5), and warns against use of UUIDs of either version as security credentials.[1]

Version 4 (random)[edit]

A version 4 UUID is randomly generated. As in other UUIDs, 4 bits are used to indicate version 4, and 2 or 3 bits to indicate the variant (102 or 1102 for variants 1 and 2 respectively). Thus, for variant 1 (that is, most UUIDs) a random version-4 UUID will have 6 predetermined variant and version bits, leaving 122 bits for the randomly generated part, for a total of 2122, or 5.3×1036 (5.3 undecillion) possible version-4 variant-1 UUIDs. There are half as many possible version-4 variant-2 UUIDs (legacy GUIDs) because there is one fewer random bit available, 3 bits being consumed for the variant.


Collision occurs when the same UUID is generated more than once and assigned to different referents. In the case of standard version-1 and version-2 UUIDs using unique MAC addresses from network cards, collisions are unlikely to occur, with an increased possibility only when an implementation varies from the standards, either inadvertently or intentionally.

In contrast to version-1 and version-2 UUID's generated using MAC addresses, with version-1 and -2 UUIDs which use randomly generated node ids, hash-based version-3 and version-5 UUIDs, and random version-4 UUIDs, collisions can occur even without implementation problems, albeit with a probability so small that it can normally be ignored. This probability can be computed precisely based on analysis of the birthday problem.[21]

For example, the number of random version-4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion, computed as follows:[22]

{\displaystyle n\approx {\frac {1}{2}}+{\sqrt {{\frac {1}{4}}+2\times \ln(2)\times 2^{122}}}\approx 2.71\times 10^{18}.}

This number is equivalent to generating 1 billion UUIDs per second for about 85 years. A file containing this many UUIDs, at 16 bytes per UUID, would be about 45 exabytes.

The smallest number of version-4 UUIDs which must be generated for the probability of finding a collision to be p is approximated by the formula

{\displaystyle {\sqrt {2\times 2^{122}\times \ln {\frac {1}{1-p}}}}.}

Thus, the probability to find a duplicate within 103 trillion version-4 UUIDs is one in a billion.


Significant uses include ext2/ext3/ext4 filesystem userspace tools (e2fsprogs uses libuuid provided by util-linux), LVM, LUKS encrypted partitions, GNOME, KDE, and macOS,[23] most of which are derived from the original implementation by Theodore Ts'o.[15]

One of the uses of UUIDs in Solaris (using Open Software Foundation implementation) is identification of a running operating system instance for the purpose of pairing crash dump data with Fault Management Event in the case of kernel panic.[24]

Commonly used within bluetooth protocols to determine services and general bluetooth profile. [25]

In COM[edit]

There are several flavors of GUIDs used in Microsoft's Component Object Model (COM):

  • IID – interface identifier; (The ones that are registered on a system are stored in the Windows Registry at [26] )
  • CLSID – class identifier; (Stored at )
  • LIBID – type library identifier; (Stored at [27])
  • CATID – category identifier; (its presence on a class identifies it as belonging to certain class categories, listed at [28])

As database keys[edit]

UUIDs are commonly used as a unique key in database tables. The NEWID function in Microsoft SQL Server version 4 Transact-SQL returns standard random version-4 UUIDs, while the NEWSEQUENTIALID function returns 128-bit identifiers similar to UUIDs which are committed to ascend in sequence until the next system reboot.[29] The Oracle DatabaseSYS_GUID function does not return a standard GUID, despite the name. Instead, it returns a 16-byte 128-bit RAW value based on a host identifier and a process or thread identifier, somewhat similar to a GUID.[30]PostgreSQL contains a UUID datatype[31] and can generate most versions of UUIDs through the use of functions from modules.[32][33]MySQL provides a UUID function, which generates standard version-1 UUIDs.[34]

The random nature of standard UUIDs of versions 3, 4, and 5, and the ordering of the fields within standard versions 1 and 2 may create problems with database locality or performance when UUIDs are used as primary keys. For example, in 2002 Jimmy Nilsson reported a significant improvement in performance with Microsoft SQL Server when the version-4 UUIDs being used as keys were modified to include a non-random suffix based on system time. This so-called "COMB" (combined time-GUID) approach made the UUIDs non-standard and significantly more likely to be duplicated, as Nilsson acknowledged, but Nilsson only required uniqueness within the application.[35] By reordering and encoding version 1 and 2 UUIDs so that the timestamp comes first, insertion performance loss can be averted.[36]

Some web frameworks, such as Laravel, have support for "timestamp first" UUIDs that may be efficiently stored in an indexed database column. This makes a COMB UUID using version 4 format, but where the first 48-bits make up a timestamp laid out like in UUIDv1.[37][38] More specified formats based on the COMB UUID idea include:

  • "ULID", which ditches the 4 bits used to indicate version 4, uses a base32 encoding by default, and mandates full monotonicity by statefulness.[39]
  • UUID versions 6 through 8, a formal proposal of three COMB UUID formats.[40]

See also[edit]


  1. ^ abcdefghijklmnLeach, P.; Mealling, M.; Salz, R. (2005). A Universally Unique IDentifier (UUID) URN Namespace. Internet Engineering Task Force. doi:10.17487/RFC4122. RFC4122. Retrieved 17 January 2017.
  2. ^"Universally Unique Identifiers (UUID)". H2. Retrieved 21 March 2021.
  3. ^ITU-T Recommendation X.667: Generation and registration of Universally Unique Identifiers (UUIDs) and their use as ASN.1 Object Identifier components. Standard. October 2012.
  4. ^Zahn, Lisa (1990). Network Computing Architecture. Prentice Hall. p. 10. ISBN .
  5. ^"CDE 1.1: Remote Procedure Call". The Open Group. 1997.
  6. ^ abc"DCE 1.1: Authentication and Security Services". The Open Group. 1997.
  7. ^"ITU-T Study Group 17 - Object Identifiers (OID) and Registration Authorities Recommendations". Retrieved 20 December 2016.
  8. ^"Registry Keys and Entries for a Type 1 Online Store". Microsoft Developer Network. Microsoft.
  9. ^Steele, Nick. "Breaking Down UUIDs".
  10. ^"UUID Versions Explained".
  11. ^Leach, Paul. "UUIDs and GUIDs".
  12. ^"Guid.ToByteArray Method".
  13. ^"uuid.c".
  14. ^"Globally Unique Identifiers". Microsoft Developer Network. Microsoft.
  15. ^ ab"ext2/e2fsprogs.git - Ext2/3/4 filesystem userspace utilities". Retrieved 9 January 2017.
  16. ^"Recommendation ITU-T X.667"(PDF). October 2012. Retrieved 19 December 2020.
  17. ^"Registration Authority". IEEE Standards Association.
  18. ^"MAC Address Setup". OpenWRT. 15 September 2021.
  19. ^Reiter, Luke (2 April 1999). "Tracking Melissa's Alter Egos". ZDNet. CBS Interactive. Retrieved 16 January 2017.
  20. ^Kuchling, A. M. "What's New in Python 2.5". Retrieved 23 January 2016.
  21. ^Jesus, Paulo; Baquero, Carlos; Almaeida, Paulo. "ID Generation in Mobile Environments"(PDF).
  22. ^Mathis, Frank H. (June 1991). "A Generalized Birthday Problem". SIAM Review. 33 (2): 265–270. CiteSeerX doi:10.1137/1033051. ISSN 0036-1445. JSTOR 2031144. OCLC 37699182.
  23. ^gen_uuid.c in Apple's Libc-391, corresponding to Mac OS X 10.4
  24. ^"Crashdump Restructuring in Solaris". Oracle. Retrieved 9 January 2017.
  25. ^"Assigned Numbers and Service Discovery Protocol".
  26. ^"Interface Pointers and Interfaces". Windows Dev Center - Desktop app technologies. Microsoft. Retrieved 15 December 2015.
  27. ^"Registering a Type Library". Microsoft Developer Network. Microsoft. Retrieved 15 December 2015.
  28. ^"Categorizing by Component Capabilities". Windows Dev Center - Desktop app technologies. Microsoft. Retrieved 15 December 2015.
  29. ^"NEWSEQUENTIALID (Transact-SQL)". Microsoft Developer Network. Microsoft. 8 August 2015. Retrieved 14 January 2017.
  30. ^"Oracle Database SQL Reference". Oracle.
  31. ^"Section 8.12 UUID Type". PostgreSQL 9.4.10 Documentation. PostgreSQL Global Development Group.
  32. ^"uuid-ossp". PostgreSQL: Documentation: 9.6. PostgreSQL Global Development Group.
  33. ^"pgcrypto". PostgreSQL: Documentation: 9.6. PostgreSQL Global Development Group.
  34. ^"Section 13.20 Miscellaneous Functions". MySQL 5.7 Reference Manual. Oracle Corporation.
  35. ^Nilsson, Jimmy (8 March 2002). InformIT. InformIT. Retrieved 20 June 2012.
  36. ^"Storing UUID Values in MySQL". Percona. 19 December 2014. Archived from the original on 29 November 2020. Retrieved 10 February 2021.
  37. ^"Helpers - Laravel - The PHP Framework For Web Artisans".
  38. ^Cabrera, Italo Baeza (31 January 2020). "Laravel: The mysterious "Ordered UUID"". Medium.
  39. ^"Universally Unique Lexicographically Sortable Identifier". GitHub. ULID. 10 May 2021.
  40. ^"draft-peabody-dispatch-new-uuid-format-01".

External links[edit]


ITU-T UUID Generator

Technical Articles


Implementation in various languages


You will also be interested:

" Several more splashes washed over the naked bodies of the. Girls. When it was over, Melanie, like Gloria, collected the semen from her breasts, belly and her father's cock and swallowed it in.

779 780 781 782 783