【问题标题】:Why are binary Guids different from usual representation为什么二进制 Guid 与通常的表示不同
【发布时间】:2011-02-15 11:29:26
【问题描述】:

我有以下指导:

AAB13E97-449B-4D5B-BDE2-AC479C31B782

使用 System.Guid + DbLinq + SQLite 存储它,将以下字段添加到数据库中。

973EB1AA-9B44-5B4D-BDE2-AC479C31B782

(为清楚起见添加了破折号)

我可以看到最后8个字节顺序相同,前3组颠倒了,但我不明白为什么。

【问题讨论】:

    标签: .net sqlite binary guid dblinq


    【解决方案1】:

    看着Wikipedia's article on the subject 它说:

    Data4 以与 GUID 文本编码中显示的顺序相同的顺序存储字节(见下文),但其他三个字段在 little-endian 系统(例如 Intel CPU)上是相反的。

    所以我得出结论:

    • 这与所使用的 DBMS 或框架无关
    • 这取决于处理器架构
    • 这是设计使然

    所以问题仍然存在:

    他们到底为什么要这样设计?

    【讨论】:

    • “他们到底为什么要这样设计?” - 我的猜测是最初 V1 GUID 在 Data4 字段中保存 MAC 地址。历史上 big-endian 被定义为标准的网络字节顺序,并用于许多与网络相关的事物,例如 IP 地址、MAC 地址等。
    • 来自维基百科:Version 1 (MAC address) Conceptually, the original (version 1) generation scheme for UUIDs was to concatenate the UUID version with the MAC address of the computer that is generating the UUID, and with the number of 100-nanosecond intervals since the adoption of the Gregorian calendar in the West. This scheme has been criticized in that it is not sufficiently "opaque"; it reveals both the identity of the computer that generated the UUID and the time at which it did so.
    猜你喜欢
    • 2012-10-04
    • 2011-08-05
    • 2020-08-02
    • 2010-11-08
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    相关资源
    最近更新 更多