[Original]uuid Brief introduction

Source: Internet
Author: User
Tags md5 hash

The UUID meaning is a universal unique identifier (universally unique Identifier), which is a software construction standard and is also used by the Open Software Foundation, OSF, to organize applications in a distributed computing environment ( Distributed Computing Environment, DCE) is part of the field.

In the application, the UUID is often used, and uuid1, Uuid4 and so on, so what exactly?

The purpose of the UUID is to allow all elements in a distributed system to have a unique identifying information, without the need to specify the information through the central control side (in other word, it guarantees that it can generate a unique string at any given time on a machine). )。 In this way, everyone can create a UUID that does not clash with others. In such a case, there is no need to consider the name duplication problem when the database is established. Currently the most widely used UUID is Microsoft's globally Unique Identifiers (GUIDs), while other important applications are the Linux ext2/ext3 file system, LUKS encryption partition, GNOME, KDE, Mac OS X, and so on.

So the UUID is a number generated on a machine that guarantees that all machines in the same time and space are unique. Based on the standard calculations developed by the Open Software Foundation (OSF), Ethernet card addresses, nanosecond time, chip ID codes, and many possible numbers are used. A combination of the following: the current date and time (the first part of the UUID is related to the time, if you generate a UUID after a few seconds, the first part is different, the rest is the same), the clock sequence, the globally unique IEEE Machine identification number (if there is a network card, from the network card, No network cards are available in other ways, theonly drawback to the UUID is that the resulting string will be longer.

The UUID is a 16-byte, 128-bit long number, usually expressed as a 36-byte string, as shown in the following example:

The c09f7392-8cd0-11e5-8559-000c2964e92b # letter is a 16 binary representation, regardless of the capitalization .

  The GUID (globally Unique Identifier) is the alias of the UUID, but in practical applications, the GUID usually refers to the UUID implemented by Microsoft.

UUID is just a code specification, it has different calculation results according to different algorithms, each algorithm has a specific range of application scenarios.

  UUID 1: time-based UUID

   The time-based UUID is obtained by calculating the current timestamp, the random number, and the machine MAC address. Since the MAC address is used in the algorithm, this version of the UUID can guarantee uniqueness globally. But at the same time, using a MAC address poses a security problem, which is where this version of the UUID has been criticized. If the application is only used in the local area network, you can also use the degraded algorithm, the IP address instead of the MAC address--java's UUID is often implemented (also considering the difficulty of acquiring a Mac).


the DCE (distributed Computing Environment) secure UUID and time-based UUID algorithm are the same, but replace the first 4 bits of the timestamp with the POSIX uid or GID. This version of the UUID is rarely used in practice.


the name-based UUID is worthwhile by calculating the MD5 hash of the name and namespace. This version of the UUID guarantees: The uniqueness of the UUID generated by different names in the same namespace, the uniqueness of the UUID in the different namespaces, and the same name in the same namespace, where the UUID duplicate generation is the same.


   
Generates a UUID based on a random number, or a pseudo-random number. The probability of the repetition of such a UUID can be calculated.


   
Similar to version 3 UUID algorithms, only hash values are computed using the SHA1 (Secure Hash algorithm 1) algorithm.

Note: There is no implementation of UUID2 in Python.

Uuid1 and Uuid2 are most suitable for use in distributed environments, UUID3 and UUID5 can be used in a small area, uuid4 because of the random, so discouragement will produce a duplicate of two random numbers, in the strict requirements of the uniqueness of the application is best not, but because it is the simplest implementation, So it can be used in other applications that you feel are appropriate.

Because UUID3 and 5 have uniqueness on the name dimension, UUID3 and 5 are preferred in scenarios where the name dimension is guaranteed to be unique.

[Original]uuid Brief introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.