Python module python UUID module

Source: Internet
Author: User
Tags md5 hash uuid

The UUID is a 128-bit globally unique identifier (Univeral unique identifier), typically expressed in the form of a 32-bit string. Sometimes also called a GUID (Global unique identifier). Python has its own UUID module for the generation and management of UUID. (It is unclear from which version.) )

The UUID module in Python is based on the UUID of information such as MAC address, timestamp, namespace, random number, pseudo-random number. There are several ways to do this:

UUID.UUID1 () generates a unique UUID based on MAC address, timestamp, and random number to guarantee uniqueness worldwide.

The UUID.UUID2 () algorithm is the same as UUID1, and the difference is that the first 4 bits of the timestamp are replaced with the POSIX UID. However, it is important to note that there is no DCE-based algorithm in Python, so there is no uuid2 this method in Python's UUID module.

UUID.UUID3 (namespace,name) gives a UUID by calculating the MD5 hash value of a namespace and a name, so that different names in the namespace have different uuid, but the same name is the same UUID. "Thank you," commented the big guy. "Namespace is not a string or other amount that you manually specify, but some of the values given in the UUID module itself. Like the UUID. Namespace_dns,uuid. Namespace_oid,uuid. Namespace_oid these values. The values themselves are UUID objects, which are calculated according to certain rules.

Uuid.uuid4 () The UUID is obtained by pseudo-random number, there is a certain probability repetition

UUID.UUID5 (Namespace,name) and UUID3 are basically the same, except that the hashing algorithm used is SHA1


Python module python UUID module

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.