Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

guid - GUID和UUID之间有什么区别吗?(Is there any difference between a GUID and a UUID?)

我看到这两个缩略词被抛出,我想知道GUID和UUID之间是否有任何区别?

  ask by Jon Tackabury translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The simple answer is: no difference , they are the same thing.

(简单的答案是: 没有区别 ,它们是一回事。)

Treat them as a 16 byte (128 bits) value that is used as a unique value.

(将它们视为16字节(128位)值,用作唯一值。)

In Microsoft-speak they are called GUIDs, but call them UUIDs when not using Microsoft-speak.

(在Microsoft中,它们被称为GUID,但在不使用Microsoft时会称它们为UUID。)

Even the authors of the UUID specification and Microsoft claim they are synonyms:

(甚至UUID规范的作者和微软都声称他们是同义词:)

  • From the introduction to IETF RFC 4122 " A Universally Unique IDentifier (UUID) URN Namespace ": "a Uniform Resource Name namespace for UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier)."

    (从IETF RFC 4122通用唯一标识符(UUID)URN命名空间 ”的介绍:“ UUID的统一资源名称命名空间(通用唯一标识符),也称为GUID(全球唯一标识符)。”)

  • From the ITU-T Recommendation X.667, ISO/IEC 9834-8:2004 International Standard : "UUIDs are also known as Globally Unique Identifiers (GUIDs), but this term is not used in this Recommendation."

    (根据ITU-T X.667建议书,ISO / IEC 9834-8:2004国际标准 :“UUID也称为全球唯一标识符(GUID),但本建议书中未使用该术语。”)

  • And Microsoft even claims a GUID is specified by the UUID RFC: "In Microsoft Windows programming and in Windows operating systems, a globally unique identifier (GUID), as specified in [RFC4122], is ... The term universally unique identifier (UUID) is sometimes used in Windows protocol specifications as a synonym for GUID."

    (微软甚至声称 UUID RFC指定了GUID:“在Microsoft Windows编程和Windows操作系统中,[RFC4122]中指定的全局唯一标识符(GUID)是......术语通用唯一标识符(UUID) )有时在Windows协议规范中用作GUID的同义词。“)

But the correct answer depends on what the question means when it says "UUID"...

(但正确的答案取决于问题的含义,当它说“UUID”时......)

The first part depends on what the asker is thinking when they are saying "UUID".

(第一部分取决于提问者在说“UUID”时的想法。)

Microsoft's claim implies that all UUIDs are GUIDs.

(微软的声明暗示所有UUID都是GUID。)

But are all GUIDs real UUIDs?

(但是所有GUID都是真正的UUID吗?)

That is, is the set of all UUIDs just a proper subset of the set of all GUIDs, or is it the exact same set?

(也就是说,所有UUID的集合只是所有GUID集的适当子集,还是完全相同的集合?)

Looking at the details of the RFC 4122, there are four different "variants" of UUIDs.

(查看RFC 4122的详细信息,UUID有四种不同的“变体”。)

This is mostly because such 16 byte identifiers were in use before those specifications were brought together in the creation of a UUID specification.

(这主要是因为在创建UUID规范之前将这些规范集合在一起之前使用了这样的16字节标识符。)

From section 4.1.1 of RFC 4122 , the four variants of UUID are:

(从RFC 4122的 4.1.1节开始,UUID的四个变体是:)

  1. Reserved, Network Computing System backward compatibility

    (保留,网络计算系统向后兼容)

  2. The variant specified in RFC 4122 (of which there are five sub-variants, which are called "versions")

    (RFC 4122中指定的变体 (其中有五个子变体,称为“版本”))

  3. Reserved, Microsoft Corporation backward compatibility

    (保留,Microsoft Corporation向后兼容)

  4. Reserved for future definition.

    (保留供将来定义。)

According to RFC 4122, all UUID variants are "real UUIDs", then all GUIDs are real UUIDs.

(根据RFC 4122,所有UUID 变体都是“真正的UUID”,然后所有GUID都是真正的UUID。)

To the literal question "is there any difference between GUID and UUID" the answer is definitely no for RFC 4122 UUIDs: no difference (but subject to the second part below).

(对于文字问题“GUID和UUID之间是否有任何区别”,对于RFC 4122 UUID,答案肯定是否定的: 没有区别 (但受下面第二部分的影响)。)

But not all GUIDs are variant 2 UUIDs (eg Microsoft COM has GUIDs which are variant 3 UUIDs).

(但并非所有GUID都是变体 2 UUID(例如,Microsoft COM具有变体3 UUID的GUID)。)

If the question was "is there any difference between GUID and variant 2 UUIDs", then the answer would be yes -- they can be different.

(如果问题是“GUID和变体2 UUID之间有什么区别”,那么答案是肯定的 - 它们可以是不同的。)

Someone asking the question probably doesn't know about variants and they might be only thinking of variant 2 UUIDs when they say the word "UUID" (eg they vaguely know of the MAC address+time and the random number algorithms forms of UUID, which are both versions of variant 2).

(有人问这个问题可能不知道变种 ,他们可能只考虑变体 2 UUID,当他们说“UUID”这个词时(例如他们模糊地知道UUID的MAC地址+时间和随机数算法形式,其中是变体 2)的两个版本 。)

In which case, the answer is yes different .

(在这种情况下,答案是肯定的 。)

So the answer, in part, depends on what the person asking is thinking when they say the word "UUID".

(所以答案在某种程度上取决于当他们说出“UUID”这个词时,他们的想法是什么。)

Do they mean variant 2 UUID (because that is the only variant they are aware of) or all UUIDs?

(它们是指变体2 UUID(因为这是他们所知道的唯一变体)还是所有UUID?)

The second part depends on which specification being used as the definition of UUID.

(第二部分取决于使用哪个规范作为UUID的定义。)

If you think that was confusing, read the ITU-T X.667 ISO/IEC 9834-8:2004 which is supposed to be aligned and fully technically compatible with RFC 4122 .

(如果您认为这令人困惑,请阅读ITU-T X.667 ISO / IEC 9834-8:2004 ,该版本应与RFC 4122保持一致并完全在技术上兼容。)

It has an extra sentence in Clause 11.2 that says, "All UUIDs conforming to this Recommendation | International Standard shall have variant bits with bit 7 of octet 7 set to 1 and bit 6 of octet 7 set to 0".

(在第11.2条中有一个额外的句子说:“符合本建议书|国际标准的所有UUID都应具有变量位,其中第7位的第7位设置为1,第7位的第6位设置为0”。)

Which means that only variant 2 UUID conform to that Standard (those two bit values mean variant 2).

(这意味着只有变体 2 UUID符合该标准(这两个位值表示变体 2)。)

If that is true, then not all GUIDs are conforming ITU-T/ISO/IEC UUIDs, because conformant ITU-T/ISO/IEC UUIDs can only be variant 2 values.

(如果确实如此,那么并非所有GUID都符合ITU-T / ISO / IEC UUID,因为符合ITU-T / ISO / IEC UUID的只能是变量 2的值。)

Therefore, the real answer also depends on which specification of UUID the question is asking about.

(因此,真正的答案还取决于问题所针对的UUID规范。)

Assuming we are clearly talking about all UUIDs and not just variant 2 UUIDs: there is no difference between GUID and IETF's UUIDs, but yes difference between GUID and conforming ITU-T/ISO/IEC's UUIDs!

(假设我们清楚地谈论所有UUID而不仅仅是变体2 UUID:GUID和IETF的UUID之间没有区别 ,但是GUID和符合 ITU-T / ISO / IEC的UUID之间是有区别的!)

Binary encodings could differ

(二进制编码可能有所不同)

When encoded in binary (as opposed to the human-readable text format), the GUID may be stored in a structure with four different fields as follows.

(当以二进制编码(与人类可读文本格式相反)时,GUID 可以存储在具有四个不同字段的结构中,如下所述。)

This format differs from the UUID standard only in the byte order of the first 3 fields.

(此格式与UUID标准的区别仅在于前3个字段的字节顺序。)

Bits  Bytes Name   Endianness  Endianness
                   (GUID)      RFC 4122

32    4     Data1  Native      Big
16    2     Data2  Native      Big
16    2     Data3  Native      Big
64    8     Data4  Big         Big

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...