GUID和UUID之间有什么区别吗? [英] Is there any difference between a GUID and a UUID?

查看:995
本文介绍了GUID和UUID之间有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这两个首字母缩写出现了,我想知道GUID和UUID之间是否有区别?

解决方案

简单答案是:**没有区别,它们是同一回事.

2020-08-20更新:尽管GUID(由Microsoft使用)和UUID(由RFC4122定义)看起来相似且具有相似的用途,但存在细微但有时重要的差异.具体来说,某些Microsoft GUID文档允许GUID包含任何十六进制数字RFC4122要求versionvariant字段具有某些值.另外,[在同一链接上] GUID应该是全大写,而UUID 输出为小写字符,输入时不区分大小写".这可能会导致代码库之间的不兼容(例如 ).

(以下为原始答案)


将它们作为一个16字节(128位)的值进行处理,该值用作唯一值.在Microsoft语言中,它们称为GUID,但在不使用Microsoft语言时,它们称为UUID.

甚至UUID规范的作者和Microsoft都声称它们是同义词:

  • 从IETF简介开始 RFC 4122 " A通用唯一标识符(UUID)URN命名空间":用于UUID(通用唯一标识符)的统一资源名称命名空间,也称为GUID(全局唯一标识符)."

  • 来自 ITU-T X.667建议书,ISO /IEC 9834-8:2004国际标准:"UUID也被称为全局唯一标识符(GUID),但在本建议书中未使用该术语."

  • Microsoft甚至声明 GUID由UUID RFC指定:在Microsoft Windows编程和Windows操作系统中,[RFC4122]中指定的全局唯一标识符(GUID)为...通用唯一标识符(UUID) )有时在Windows协议规范中用作GUID的同义词.

但是正确答案取决于该问题在显示"UUID"时的含义...

第一部分取决于提问者在说"UUID"时的想法.

Microsoft的声明暗示所有UUID都是GUID.但是,所有GUID都是真正的UUID吗?也就是说,所有UUID的集合只是所有GUID的集合的适当子集,还是完全相同的集合?

看看RFC 4122的细节,有四个不同的变体".的UUID.这主要是因为在创建UUID规范之前,已经使用了16个字节的标识符.在 RFC 4122 的4.1.1节中,有四个变体的UUID是:

  1. 保留的网络计算系统向后兼容性
  2. RFC 4122中指定的变体(其中有五个子变体,称为版本")
  3. 保留,Microsoft Corporation向后兼容
  4. 保留以供将来定义.

根据RFC 4122,所有UUID 变体都是真实UUID",然后所有GUID都是真实UUID.对于字面问题,"GUID和UUID之间是否有任何区别"?对于RFC 4122 UUID,答案肯定是否":没有区别(但受下面第二部分的约束).

但不是所有的GUID都是 variant 2个UUID(例如,Microsoft COM的GUID是3个UUID).如果问题是"GUID和变体2 UUID之间是否有任何区别",那么答案将是-它们可以不同.有人问这个问题可能对 variant 并不了解,当他们说"UUID" 2个UUID时,他们可能只会想到 variant 2个UUID. (例如,他们隐约知道MAC地址+时间和UUID的随机数算法形式,它们都是 variant 2的 version ).在这种情况下,答案是是不同.

因此,答案部分取决于询问者在说出"UUID"一词时的想法.它们是指变体2 UUID(因为这是他们知道的唯一变体)还是所有UUID?

第二部分取决于哪个规范用作UUID的定义.

如果您认为这令人困惑,请阅读 ITU-TX. 667 ISO/IEC 9834-8:2004 ,应该与 RFC 4122 .在条款11.2中有一个额外的句子,其中说:符合本建议书的所有UUID |国际标准应具有变种比特,其八比特组7的比特7设置为1,八比特组7的比特6设置为"0".这意味着只有 variant 2 UUID符合该标准(这两个比特值表示 variant 2).如果是这样,那么并不是所有的GUID都符合ITU-T/ISO/IEC UUID,因为符合的ITU-T/ISO/IEC UUID只能是 variant 2个值.

因此,真正的答案还取决于问题所询问的UUID规范.假设我们清楚地讨论了所有UUID,而不仅仅是2种UUID:GUID和IETF的UUID之间没有没有区别,但是GUID和符合 ITU-T/ISO/IEC的UUID!

二进制编码可能不同

以二进制格式(与人类可读的文本格式相反)进行编码时,可以存储GUID /a>在具有四个不同字段的结构中,如下所示.此格式仅在前三个字段的字节顺序中与[UUID标准] 8 不同.

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

I see these 2 acronyms thrown around, and I was wondering if there are any differences between a GUID and a UUID?

解决方案

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

2020-08-20 Update: While GUIDs (as used by Microsoft) and UUIDs (as defined by RFC4122) look similar and serve similar purposes, there are subtle-but-occasionally-important differences. Specifically, some Microsoft GUID docs allow GUIDs to contain any hex digit in any position, while RFC4122 requires certain values for the version and variant fields. Also, [per that same link], GUIDs should be all-upper case, whereas UUIDs should be "output as lower case characters and are case insensitive on input". This can lead to incompatibilities between code libraries (such as this).

(Original answer follows)


Treat them as a 16 byte (128 bits) value that is used as a unique value. In Microsoft-speak they are called GUIDs, but call them UUIDs when not using Microsoft-speak.

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

  • 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)."

  • 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."

  • 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."

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

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

Microsoft's claim implies that all UUIDs are GUIDs. But are all GUIDs real UUIDs? 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?

Looking at the details of the RFC 4122, there are four different "variants" of UUIDs. This is mostly because such 16 byte identifiers were in use before those specifications were brought together in the creation of a UUID specification. From section 4.1.1 of RFC 4122, the four variants of UUID are:

  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")
  3. Reserved, Microsoft Corporation backward compatibility
  4. Reserved for future definition.

According to RFC 4122, all UUID variants are "real UUIDs", then all GUIDs are real UUIDs. 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).

But not all GUIDs are variant 2 UUIDs (e.g. Microsoft COM has GUIDs which are variant 3 UUIDs). If the question was "is there any difference between GUID and variant 2 UUIDs", then the answer would be yes -- they can be different. 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" (e.g. they vaguely know of the MAC address+time and the random number algorithms forms of UUID, which are both versions of variant 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". Do they mean variant 2 UUID (because that is the only variant they are aware of) or all UUIDs?

The second part depends on which specification being used as the definition of 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. 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". Which means that only variant 2 UUID conform to that Standard (those two bit values mean variant 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.

Therefore, the real answer also depends on which specification of UUID the question is asking about. 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!

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. This format differs from the [UUID standard] 8 only in the byte order of the first 3 fields.

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

这篇关于GUID和UUID之间有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆