当前位置: 首页 > 知识库问答 >
问题:

UUID格式:8-4-4-4-12 -为什么?

娄振
2023-03-14

为什么UUID的格式是“8-4-4-4-12”(数字)?我环顾四周,但找不到需要它的决定。

格式化为十六进制字符串的UUID示例:58d 5 e 212-165 b-4ca 0-909 b-c 86 b 9 ce 0111

共有3个答案

仲鸿风
2023-03-14

“8-4-4-4-12”格式只是供人类阅读。UUID实际上是一个128位的数字。

考虑到字符串格式在存储或存储在内存中时需要比128位数多一倍的字节。我建议在内部使用数字,当需要在UI上显示或在文件中导出时,使用字符串格式。

微生毅
2023-03-14

格式在第3节的IETF RFC4122中定义。输出格式在它说“UUID=…”的地方定义

3.-名称空间注册模板

名称空间ID: UUID注册信息:注册日期:2003-10-01

名称空间的声明注册人:JTC 1/SC6(ASN.1报告组)

句法结构声明:UUID 是相对于所有 UUID 的空间而言,在空间和时间上都是唯一的标识符。由于 UUID 是固定大小并包含时间字段,因此值可能会滚动更新(公元 3400 年左右,具体取决于所使用的特定算法)。UUID 可用于多种用途,从标记生命周期极短的对象到可靠地识别网络中非常持久的对象。

  The internal representation of a UUID is a specific sequence of
  bits in memory, as described in Section 4.  To accurately
  represent a UUID as a URN, it is necessary to convert the bit
  sequence to a string representation.

  Each field is treated as an integer and has its value printed as a
  zero-filled hexadecimal digit string with the most significant
  digit first.  The hexadecimal values "a" through "f" are output as
  lower case characters and are case insensitive on input.

  The formal definition of the UUID string representation is
  provided by the following ABNF [7]:

  UUID                   = time-low "-" time-mid "-"
                           time-high-and-version "-"
                           clock-seq-and-reserved
                           clock-seq-low "-" node
  time-low               = 4hexOctet
  time-mid               = 2hexOctet
  time-high-and-version  = 2hexOctet
  clock-seq-and-reserved = hexOctet
  clock-seq-low          = hexOctet
  node                   = 6hexOctet
  hexOctet               = hexDigit hexDigit
  hexDigit =
        "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" /
        "a" / "b" / "c" / "d" / "e" / "f" /
        "A" / "B" / "C" / "D" / "E" / "F"
范浩荡
2023-03-14

它由时间、版本、clock_seq_hi、clock_seq_lo、节点分隔,如以下rfc所示。

根据IETF RFC4122:

4.1.2.  Layout and Byte Order

   To minimize confusion about bit assignments within octets, the UUID
   record definition is defined only in terms of fields that are
   integral numbers of octets.  The fields are presented with the most
   significant one first.

   Field                  Data Type     Octet  Note
                                        #

   time_low               unsigned 32   0-3    The low field of the
                          bit integer          timestamp

   time_mid               unsigned 16   4-5    The middle field of the
                          bit integer          timestamp

   time_hi_and_version    unsigned 16   6-7    The high field of the
                          bit integer          timestamp multiplexed
                                               with the version number  

   clock_seq_hi_and_rese  unsigned 8    8      The high field of the
   rved                   bit integer          clock sequence
                                               multiplexed with the
                                               variant

   clock_seq_low          unsigned 8    9      The low field of the
                          bit integer          clock sequence

   node                   unsigned 48   10-15  The spatially unique
                          bit integer          node identifier

   In the absence of explicit application or presentation protocol
   specification to the contrary, a UUID is encoded as a 128-bit object,
   as follows:

   The fields are encoded as 16 octets, with the sizes and order of the
   fields defined above, and with each field encoded with the Most
   Significant Byte first (known as network byte order).  Note that the
   field names, particularly for multiplexed fields, follow historical
   practice.

   0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                          time_low                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |       time_mid                |         time_hi_and_version   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |clk_seq_hi_res |  clk_seq_low  |         node (0-1)            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                         node (2-5)                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 类似资料:
  • 我使用Spring 4.1.6.RELEASE Hibernate 4.3.8.Final。在Tomcat 7上配置并启动web应用程序后,我的sessionFactory==null。 你能写出我做错了什么吗?以下是我的消息来源: pom.xml web.xml spring.xml 这是我的DAO层。我为CRUD操作和具有特定方法的子类创建基本抽象类Abstract道。 AbstractDao

  • 4. IP数据报格式 IP数据报的格式如下(这里只讨论IPv4)(该图出自[TCPIP]): 图 36.8. IP数据报格式 IP数据报的首部长度和数据长度都是可变长的,但总是4字节的整数倍。对于IPv4,4位版本字段是4。4位首部长度的数值是以4字节为单位的,最小值为5,也就是说首部长度最小是4x5=20字节,也就是不带任何选项的IP首部,4位能表示的最大值是15,也就是说首部长度最大是60字节

  • IBM WebSphere Portal Server_8.0.0.0 IBM Web Content Manager_8.0.0.0 我需要为WCM工作流创建一个自定义操作;到目前为止,我可以通过以下链接创建一个非常简单的自定义操作:WCM自定义操作 现在我需要创建一个更复杂的自定义操作;在我的自定义操作中,我希望使用Spring4.0和Hibernate4.3.0;所以我创建了一个EAR文件和

  • 4

    Lab1还差最后一部分,就是给出具体的调试信息,如下面所示: K> backtrace Stack backtrace: ebp f010ff78 eip f01008ae args 00000001 f010ff8c 00000000 f0110580 00000000 kern/monitor.c:143: monitor+106 ebp f010

  • 本章起教程进入 不那么基础的 阶段,开始涉及函数式编程概念。 对之前没有函数式编程经验的人来说,这一章是一个基础,需要好好学习和理解。 在Elixir中,=运算符实际上叫做 匹配运算符。 本章将讲解如何使用=运算符来对各种数据结构进行模式匹配。 最后本章还会讲解pin运算符(^),用来访问某变量之前绑定的值。 4.1-匹配运算符 我们已经多次使用=符号进行变量的赋值操作: iex> x = 1 1

  • 使用检查器面板,你可以对图层进行任意调整。 常规选项 检查器面板的第一部分,可以针对所选中的形状,进行包括位置、混合模式、不透明度以及一些特殊选项的修改。例如:如果你已经选择了一个矩形,它将会显示出一个滑块来调节圆角半径。 边框 可以使用实心颜色或者渐变颜色来为图层添加边框(Border)或称描边(Stroke),描边的位置有外部(Outer)、居中(Center)或者内部(Inner)可选。 想