Universally Unique Identifier
From Wikipedia, the free encyclopedia
A Universally Unique Identifier is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination. Thus, anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else. Information labelled with UUIDs can therefore be later combined into a single database without needing to resolve name conflicts. The most widespread use of this standard is in Microsoft's Globally Unique Identifiers (GUIDs) which implement this standard. Other significant users include Linux's ext2/ext3 filesystem, LUKS encrypted partitions, GNOME, KDE, and Mac OS X, all of which use implementations derived from the uuid library found in the e2fsprogs package.
A UUID is essentially a 16-byte (128-bit) number. In its canonical hexadecimal form a UUID may look like this:
550e8400-e29b-41d4-a716-446655440000
The number of theoretically possible UUIDs is therefore 2128 = 25616 or about 3.4 × 1038. This means that 1 trillion UUIDs have to be created every nanosecond for 10 billion years to exhaust the number of UUIDs.
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 (freely available). The IETF has published Proposed Standard RFC 4122 that is technically equivalent with ITU-T Rec. X.667 | ISO/IEC 9834-8.
Contents |
[edit] Version
[edit] Version 1 (MAC address)
Conceptually, the original (version 1) generation scheme for UUIDs was to concatenate the UUID version with the MAC address of the computer that is generating the UUID, and with the number of 100-nanosecond intervals since the adoption of the Gregorian calendar. In practice, the actual algorithm is more complicated. This scheme has been criticized in that it is not sufficiently 'opaque'; it reveals both the identity of the computer that generated the UUID and the time at which it did so.
[edit] Version 3 (MD5 hash)
Version 3 UUIDs use a scheme deriving a UUID from a URL via MD5.
[edit] Version 4 (random)
Version 4 UUIDs use a scheme relying only on random numbers.
[edit] Version 5 (SHA-1 hash)
Version 5 UUIDs use a scheme with SHA-1 (version 5 UUIDs) hashing.
[edit] Implementations
[edit] C
The OSSP project provides a UUID [1] library.
[edit] Java
The J2SE 5.0 release of Java provides a class that will produce 128-bit UUIDs, although it only implements version 3 and 4 generation methods, not the original method (due to lack of means to access MAC addresses using pure Java). The API documentation for the java.util.UUID
class refers to ISO/IEC 11578:1996.
[edit] .NET Framework
The .NET Framework also provides a class called System.Guid to generate and manipulate 128-bit UUIDs. [2]
[edit] PHP
In PHP there are several modules for creating UUIDs. [3]
[edit] Perl
The Data::UUID [4] module from CPAN can be used to create UUIDs
[edit] Python
The uuid module [5] (built-in since Python 2.5) creates UUIDs to RFC 4122.
[edit] Ruby
There are several RFC4122 implementations for Ruby, the most updated ones being Ruby-UUID and UUID
[edit] Random UUID Probability of Duplicates
Randomly generated UUIDs like those generated by the java.util.UUID
class have 122 random bits. 4 bits are used for the version ('Randomly generated UUID'), and 2 bits for the variant ('Leach-Salz'). With random UUIDs, the chance of two having the same value can be calculated using probability theory (Birthday Paradox). Using the approximation
these are the probabilities after calculating x UUIDs:
x | probability |
---|---|
68'719'476'736 = 236 | 0.000'000'000'000'000'4 |
2'199'023'255'552 = 241 | 0.000'000'000'000'4 |
70'368'744'177'664 = 246 | 0.000'000'000'4 |
Of course, the probability also depends on the quality of the random number generator. For use in critical security applications, a Cryptographically secure pseudorandom number generator must be used to generate the values.
One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion[citation needed], that means the probability is about 0.000'000'000'06.
[edit] See also
[edit] External links
- International Standard "Generation and registration of Universally Unique Identifiers (UUIDs) and their use as ASN.1 Object Identifier components" (ITU-T Rec. X.667 | ISO/IEC 9834-8, freely available)
- A Universally Unique IDentifier (UUID) URN Namespace (IETF RFC 4122)
- Extract the time from a version 1 UUID / GUID
- Global UUID registration function at ITU-T
- Portable implementation providing a C API, Perl API and Unix CLI
- Commons Id
- Java Uuid Generator (JUG)
- ISO/IEC 11578:1996
- DmaId for InstanceId Values (DCE Universally Unique IDentifiers, UUIDs)
- Syntax and semantics of the DCE variant of Universal Unique Identifiers (UUIDs)
- UUID generation module for Python (documentation)
- UUID generation module for Python (code)
- Random UUID Probability of Duplicates
- Java 5 UUID class
- UUID generation module for Perl