I am creating some Jenkins tokens for githooks and I was using uuidgen
.
My coworker said they normally use uuid -v4
and after sudo apt-get
-ing uuid
, uuid -v4
and uuidgen
appear to be the same:
$ uuid -v4
832dce77-ddec-4cc5-9872-47a81456653f
$ uuidgen
a321bc87-a1b5-4cc5-b6b5-feaf3a610ab8
For reference: I am running this on Ubuntu.
What is the difference between them? Are they they same?
tldr; they're both random since uuidgen
== uuidgen -r
== uuid -v4
The man 1 uuidgen
doesn't say so, but uuidgen -t
and uuidgen -r
are, respectively, producing version 1 ("time and node based") and version 4 ("random data based") UUIDs as dictated by ISO/IEC 11578:1996.
$ { 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)
References:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With