gpt4 book ai didi

uuid - uuid -v4 和 uuidgen 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 23:17:35 25 4
gpt4 key购买 nike

我正在为 githooks 创建一些 Jenkins token ,并且我正在使用 uuidgen

我的同事说他们通常使用 uuid -v4 并且在 sudo apt-get -ing uuid 之后,uuid -v4uuidgen 看起来是一样的:

$ uuid -v4
832dce77-ddec-4cc5-9872-47a81456653f
$ uuidgen
a321bc87-a1b5-4cc5-b6b5-feaf3a610ab8

供引用:我在 Ubuntu 上运行它。

它们之间有什么区别?他们是一样的吗?

最佳答案

tldr;它们都是随机的,因为 uuidgen == uuidgen -r == uuid -v4
man 1 uuidgen 没有这么说,但是 uuidgen -tuuidgen -r 分别产生了 ISO/IEC 11578:1996 规定的版本 1(“基于时间和节点”)和版本 4(“基于随机数据”)UUID。

$ { uuidgen -t && uuidgen -r && uuid -v1 && uuid -v4 ; } | xargs -L1 uuid -d

encode: STR: 5f441c74-c63a-11e7-8cb0-0242ac110002
SIV: 126630312945231364299766443008257490946
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 1 (time and node based)
content: time: 2017-11-10 17:12:46.679154.0 UTC
clock: 3248 (usually random)
node: 02:42:ac:11:00:02 (local unicast)
encode: STR: d70f042a-c5ca-4726-b259-795e47fd1b95
SIV: 285861988065069261246745478758429170581
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 4 (random data based)
content: D7:0F:04:2A:C5:CA:07:26:32:59:79:5E:47:FD:1B:95
(no semantics: random data only)
encode: STR: 5f443b5a-c63a-11e7-8cd2-0242ac110002
SIV: 126630939639996852130686378090112811010
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 1 (time and node based)
content: time: 2017-11-10 17:12:46.679945.0 UTC
clock: 3282 (usually random)
node: 02:42:ac:11:00:02 (local unicast)
encode: STR: 09432e97-a1fc-4e05-9492-7c0c11ec0abc
SIV: 12311880856012488273304867468361861820
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 4 (random data based)
content: 09:43:2E:97:A1:FC:0E:05:14:92:7C:0C:11:EC:0A:BC
(no semantics: random data only)

引用:
  • https://en.wikipedia.org/wiki/Universally_unique_identifier
  • https://linux.die.net/man/1/uuidgen
  • https://linux.die.net/man/1/uuid
  • 关于uuid - uuid -v4 和 uuidgen 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47227293/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com