有没有办法区分 GUID 和随机数?

发布于 2024-08-12 03:37:26 字数 396 浏览 2 评论 0原文

在调试模糊的代码缺陷时,能够将 GUID 与随机数据区分开来非常有用。

在 Windows 上,生成的每个 GUID 都是版本 4,因此它的第三部分的前半字节为“4”。因此,如果 16 字节序列违反了该规则,那么它就不是版本 4 GUID。例如,

567E1ECB-EA1C-42D3-A3ED-87A5D824D167

可以是版本 4 GUID 或其他任何内容,但

567E1ECB-EA1C-02D3-A3ED-87A5D824D167 //third section starts with 0, not with 4

不是版本 4 GUID。

16 字节内存块是否为有效 GUID 的其他标志有哪些?

Being able to distinguish a GUID from random data can be useful when debugging obscure code defects.

On Windows each GUID generated is of version 4 therefore it has '4' as the first half-byte of the third part. So if the 16-byte sequence violtates that rule it is not a version 4 GUID. For example,

567E1ECB-EA1C-42D3-A3ED-87A5D824D167

could be either a version 4 GUID or anything else, but

567E1ECB-EA1C-02D3-A3ED-87A5D824D167 //third section starts with 0, not with 4

is not a version 4 GUID.

What are other signs of a 16-byte memory block being or not being a valid GUID?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左耳近心 2024-08-19 03:37:26

GUID 是十六进制的,因此您可以检查包含哪些字符(即“X”、“Y”等无效)。

检查维基百科的定义,您可能会在那里找到更多想法。

http://en.wikipedia.org/wiki/Globally_Unique_Identifier

GUID's are hexadecimal, so you could check what characters are included (i.e. 'X', 'Y', etc. are not valid)

Check wikipedia for the definition and you could probably find out more ideas there.

http://en.wikipedia.org/wiki/Globally_Unique_Identifier

沐歌 2024-08-19 03:37:26

除了 GUID 版本 (0100) 之外,还有一种称为 GUID 变体的东西。这将是八位字节 8 中的 2 位 (10)。 v4 GUID 的其余位 a 根据定义是随机的。

Besides GUID version (0100), there's also something called the GUID variant. This will be 2 bits (10) in octet 8. The remaining bits a of v4 GUID are by definition random.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文