UUID (GUID)

Last Updated: 2023-05-26 09:50:58 Friday

-- TOC --

维基百科GUID的页面被重定向到了UUID,看来他们就是同一个概念。

A universally unique identifier (UUID) is a 128-bit label used for information in computer systems. The term globally unique identifier (GUID) is also used.

UUID长16Bytes,有标准的多个生成算法(RFC4122),算法的计算可能会用到Mac地址和datetime等信息。有碰撞的可能,但是概率极低,低到可以被忽略。获得UUID,不需要通过任何中心化的组织分配。

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 generally considered close enough to zero to be negligible.

任何人都可以随意创建UUID,并使用它来作为实体标识符。由于UUID发生重复的概率极低,不同组织使用UUID标识的系统,可以轻松合并。

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.

UUID已经被广泛使用。

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

UUID的表示方法:

123e4567-e89b-12d3-a456-426614174000
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx  # version-1, variant-1

Form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4 hyphens). The four bits of digit M are the UUID version, and the 1 to 3 most significant bits of digit N code the UUID variant. In the example above, M is 1, and N is a (10xx2), meaning that this is a version-1, variant-1 UUID; that is, a time-based DCE/RFC 4122 UUID.

nil UUID,全0:

00000000-0000-0000-0000-000000000000

Python标准库中的uuid模块:

https://docs.python.org/3/library/uuid.html

本文链接:https://cs.pynote.net/sf/202305242/

-- EOF --

-- MORE --