| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::CPANModules::UUID; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
439110
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
53
|
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
625
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
7
|
|
|
|
|
|
|
our $DATE = '2023-10-30'; # DATE |
|
8
|
|
|
|
|
|
|
our $DIST = 'Acme-CPANModules-UUID'; # DIST |
|
9
|
|
|
|
|
|
|
our $VERSION = '0.011'; # VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $LIST = { |
|
12
|
|
|
|
|
|
|
summary => 'List of modules that can generate immutable universally unique identifier (UUIDs)', |
|
13
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
UUIDs (Universally Unique Identifiers), sometimes also called GUIDs (Globally |
|
16
|
|
|
|
|
|
|
Unique Identifiers), are 128-bit numbers that can be used as permanent IDs or |
|
17
|
|
|
|
|
|
|
keys in databases. There are several standards that specify UUID, one of which |
|
18
|
|
|
|
|
|
|
is RFC 4122 (2005), which we will follow in this document. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
UUIDs are canonically represented as 32 hexadecimal digits in the form of: |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
There are several variants of UUID. The variant information is encoded using 1-3 |
|
25
|
|
|
|
|
|
|
bits in the `N` position. RFC 4122 defines 4 variants (0 to 3), two of which (0 |
|
26
|
|
|
|
|
|
|
and 3) are for legacy UUIDs, so that leaves variants 1 and 2 as the current |
|
27
|
|
|
|
|
|
|
specification. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
There are 5 "versions" of UUID for both variants 1 & 2, each might be more |
|
30
|
|
|
|
|
|
|
suitable than others in specific cases. The version information is encoded in |
|
31
|
|
|
|
|
|
|
the M position. Version 1 (v1) UUIDs are generated from a time and a node ID |
|
32
|
|
|
|
|
|
|
(usually the MAC address); version 2 (v2) UUIDs from an identifier (group/user |
|
33
|
|
|
|
|
|
|
ID), a time, and a node ID; version 4 (v4) UUIDs from a rando/mpseudo-random |
|
34
|
|
|
|
|
|
|
number; version 3 (v3) UUIDs from hashing a namespace using MD5; version 5 (v5) |
|
35
|
|
|
|
|
|
|
from hashing a namespace using SHA-1. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
should be your first choice, and when you cannot install XS |
|
38
|
|
|
|
|
|
|
modules you can use instead. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Aside from the modules listed as entries below, there are also: |
|
41
|
|
|
|
|
|
|
(containing CLIs to create/check UUID), |
|
42
|
|
|
|
|
|
|
(currently just a wrapper for Data::UUID). |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MARKDOWN |
|
45
|
|
|
|
|
|
|
entry_features => { |
|
46
|
|
|
|
|
|
|
v4_rfc4122 => {summary => 'Whether the generated v4 UUID follows RFC 4122 specification (i.e. encodes variant and version information in M & N positions)'}, |
|
47
|
|
|
|
|
|
|
v4_secure_random => {summary => 'Whether the module uses cryptographically secure pseudo-random number generator for v4 UUIDs'}, |
|
48
|
|
|
|
|
|
|
}, |
|
49
|
|
|
|
|
|
|
entries => [ |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
|
|
|
|
|
|
module => 'Data::UUID', |
|
52
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module creates v1 and v2 UUIDs. Depending on the OS, for MAC address, it |
|
55
|
|
|
|
|
|
|
usually uses a hash of hostname instead. This module is XS, so performance is |
|
56
|
|
|
|
|
|
|
good. If you cannot use an XS module, try instead. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v1 string UUIDs. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
MARKDOWN |
|
61
|
|
|
|
|
|
|
bench_code_template => 'my $u = Data::UUID->new; $u->create for 1..1000; $u->to_string($u->create)', |
|
62
|
|
|
|
|
|
|
features => { |
|
63
|
|
|
|
|
|
|
is_xs => 1, |
|
64
|
|
|
|
|
|
|
is_pp => 0, |
|
65
|
|
|
|
|
|
|
create_v1 => 1, |
|
66
|
|
|
|
|
|
|
create_v2 => 1, |
|
67
|
|
|
|
|
|
|
create_v3 => 0, |
|
68
|
|
|
|
|
|
|
create_v4 => 0, |
|
69
|
|
|
|
|
|
|
create_v5 => 0, |
|
70
|
|
|
|
|
|
|
}, |
|
71
|
|
|
|
|
|
|
}, |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
{ |
|
74
|
|
|
|
|
|
|
module => 'UUID::FFI', |
|
75
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This module provides access to libuuid via the FFI interface. It can create v1 |
|
78
|
|
|
|
|
|
|
as well as v4 (random) UUIDs. Note that Data::UUID (XS-based) is faster this |
|
79
|
|
|
|
|
|
|
module (FFI-based). |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v1 string UUIDs. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
MARKDOWN |
|
84
|
|
|
|
|
|
|
bench_code_template => 'UUID::FFI->new_time for 1..1000; UUID::FFI->new_time->as_hex', |
|
85
|
|
|
|
|
|
|
features => { |
|
86
|
|
|
|
|
|
|
is_xs => 1, |
|
87
|
|
|
|
|
|
|
is_pp => 0, |
|
88
|
|
|
|
|
|
|
create_v1 => 1, |
|
89
|
|
|
|
|
|
|
create_v2 => 0, |
|
90
|
|
|
|
|
|
|
create_v3 => 0, |
|
91
|
|
|
|
|
|
|
create_v4 => 1, |
|
92
|
|
|
|
|
|
|
v4_secure_random => 0, |
|
93
|
|
|
|
|
|
|
v4_rfc4122 => 1, |
|
94
|
|
|
|
|
|
|
create_v5 => 0, |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
}, |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
{ |
|
99
|
|
|
|
|
|
|
module => 'UUID::Tiny', |
|
100
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This module should be your go-to choice if you cannot use an XS module. It can |
|
103
|
|
|
|
|
|
|
create v1, v3, v4 UUIDs. However, the random v4 UUIDs are not cryptographically |
|
104
|
|
|
|
|
|
|
secure; if you need cryptographically secure random UUIDs, use . |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v1 string UUIDs. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See also: which is a type library that uses Data::UUID as the |
|
109
|
|
|
|
|
|
|
backend. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
MARKDOWN |
|
112
|
|
|
|
|
|
|
bench_code_template => 'UUID::Tiny::create_uuid() for 1..1000; UUID::Tiny::uuid_to_string(UUID::Tiny::create_uuid())', |
|
113
|
|
|
|
|
|
|
features => { |
|
114
|
|
|
|
|
|
|
is_xs => 0, |
|
115
|
|
|
|
|
|
|
is_pp => 1, |
|
116
|
|
|
|
|
|
|
create_v1 => 1, |
|
117
|
|
|
|
|
|
|
create_v2 => 0, |
|
118
|
|
|
|
|
|
|
create_v3 => 1, |
|
119
|
|
|
|
|
|
|
create_v4 => 1, |
|
120
|
|
|
|
|
|
|
v4_secure_random => 0, |
|
121
|
|
|
|
|
|
|
v4_rfc4122 => 1, |
|
122
|
|
|
|
|
|
|
create_v5 => 1, |
|
123
|
|
|
|
|
|
|
}, |
|
124
|
|
|
|
|
|
|
}, |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
{ |
|
127
|
|
|
|
|
|
|
module => 'UUID::Random', |
|
128
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This module simply uses 32 calls to Perl's C to construct each random |
|
131
|
|
|
|
|
|
|
hexadecimal digits of the UUID (v4). Not really recommended, since perl's |
|
132
|
|
|
|
|
|
|
default pseudo-random generator is neither cryptographically secure nor has 128 |
|
133
|
|
|
|
|
|
|
bit of entropy. It also does not produce v4 UUIDs that conform to RFC 4122 (no |
|
134
|
|
|
|
|
|
|
encoding of variant & version information). |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
To create a cryptographically secure random UUIDs, use . |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v4 string UUIDs. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
MARKDOWN |
|
141
|
|
|
|
|
|
|
bench_code_template => 'UUID::Random::generate() for 1..1000; ; UUID::Random::generate()', |
|
142
|
|
|
|
|
|
|
features => { |
|
143
|
|
|
|
|
|
|
is_xs => 0, |
|
144
|
|
|
|
|
|
|
is_pp => 1, |
|
145
|
|
|
|
|
|
|
create_v1 => 0, |
|
146
|
|
|
|
|
|
|
create_v2 => 0, |
|
147
|
|
|
|
|
|
|
create_v3 => 0, |
|
148
|
|
|
|
|
|
|
create_v4 => 1, |
|
149
|
|
|
|
|
|
|
v4_secure_random => 0, |
|
150
|
|
|
|
|
|
|
v4_rfc4122 => 0, |
|
151
|
|
|
|
|
|
|
create_v5 => 0, |
|
152
|
|
|
|
|
|
|
}, |
|
153
|
|
|
|
|
|
|
}, |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
{ |
|
156
|
|
|
|
|
|
|
module => 'UUID::Random::PERLANCAR', |
|
157
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Just another implementation of . |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v4 string UUIDs. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
MARKDOWN |
|
164
|
|
|
|
|
|
|
features => { |
|
165
|
|
|
|
|
|
|
is_xs => 0, |
|
166
|
|
|
|
|
|
|
is_pp => 1, |
|
167
|
|
|
|
|
|
|
create_v1 => 0, |
|
168
|
|
|
|
|
|
|
create_v2 => 0, |
|
169
|
|
|
|
|
|
|
create_v3 => 0, |
|
170
|
|
|
|
|
|
|
create_v4 => 1, |
|
171
|
|
|
|
|
|
|
v4_secure_random => 0, |
|
172
|
|
|
|
|
|
|
v4_rfc4122 => 1, |
|
173
|
|
|
|
|
|
|
create_v5 => 0, |
|
174
|
|
|
|
|
|
|
}, |
|
175
|
|
|
|
|
|
|
functions => { |
|
176
|
|
|
|
|
|
|
generate => { |
|
177
|
|
|
|
|
|
|
bench_code_template => 'UUID::Random::PERLANCAR::generate() for 1..1000; UUID::Random::PERLANCAR::generate()', |
|
178
|
|
|
|
|
|
|
}, |
|
179
|
|
|
|
|
|
|
generate_rfc => { |
|
180
|
|
|
|
|
|
|
bench_code_template => 'UUID::Random::PERLANCAR::generate_rfc() for 1..1000; UUID::Random::PERLANCAR::generate_rfc()', |
|
181
|
|
|
|
|
|
|
}, |
|
182
|
|
|
|
|
|
|
}, |
|
183
|
|
|
|
|
|
|
}, |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
{ |
|
186
|
|
|
|
|
|
|
module => 'UUID::Random::Secure', |
|
187
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Just like , except it uses 's |
|
190
|
|
|
|
|
|
|
`irand()` to produce random numbers. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v4 string UUIDs. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
MARKDOWN |
|
195
|
|
|
|
|
|
|
features => { |
|
196
|
|
|
|
|
|
|
is_xs => 0, |
|
197
|
|
|
|
|
|
|
is_pp => 1, |
|
198
|
|
|
|
|
|
|
create_v1 => 0, |
|
199
|
|
|
|
|
|
|
create_v2 => 0, |
|
200
|
|
|
|
|
|
|
create_v3 => 0, |
|
201
|
|
|
|
|
|
|
create_v4 => 1, |
|
202
|
|
|
|
|
|
|
v4_secure_random => 1, |
|
203
|
|
|
|
|
|
|
v4_rfc4122 => 1, |
|
204
|
|
|
|
|
|
|
create_v5 => 0, |
|
205
|
|
|
|
|
|
|
}, |
|
206
|
|
|
|
|
|
|
functions => { |
|
207
|
|
|
|
|
|
|
generate => { |
|
208
|
|
|
|
|
|
|
bench_code_template => 'UUID::Random::Secure::generate() for 1..1000; UUID::Random::Secure::generate()', |
|
209
|
|
|
|
|
|
|
}, |
|
210
|
|
|
|
|
|
|
generate_rfc => { |
|
211
|
|
|
|
|
|
|
bench_code_template => 'UUID::Random::Secure::generate_rfc() for 1..1000; UUID::Random::Secure::generate_rfc()', |
|
212
|
|
|
|
|
|
|
}, |
|
213
|
|
|
|
|
|
|
}, |
|
214
|
|
|
|
|
|
|
}, |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
{ |
|
217
|
|
|
|
|
|
|
module => 'Crypt::Misc', |
|
218
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This module from the distribution has a function to create and check |
|
221
|
|
|
|
|
|
|
v4 UUIDs. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
The benchmark code creates 1000+1 v4 string UUIDs. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
MARKDOWN |
|
226
|
|
|
|
|
|
|
bench_code_template => 'Crypt::Misc::random_v4uuid() for 1..1000; Crypt::Misc::random_v4uuid()', |
|
227
|
|
|
|
|
|
|
features => { |
|
228
|
|
|
|
|
|
|
is_xs => 0, |
|
229
|
|
|
|
|
|
|
is_pp => 1, |
|
230
|
|
|
|
|
|
|
create_v1 => 0, |
|
231
|
|
|
|
|
|
|
create_v2 => 0, |
|
232
|
|
|
|
|
|
|
create_v3 => 0, |
|
233
|
|
|
|
|
|
|
create_v4 => 1, |
|
234
|
|
|
|
|
|
|
v4_secure_random => 1, |
|
235
|
|
|
|
|
|
|
v4_rfc4122 => 1, |
|
236
|
|
|
|
|
|
|
create_v5 => 0, |
|
237
|
|
|
|
|
|
|
}, |
|
238
|
|
|
|
|
|
|
}, |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
{ |
|
241
|
|
|
|
|
|
|
module => 'UUID', |
|
242
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This module generates DCE-compatible UUIDs, which according to RFC belongs to |
|
245
|
|
|
|
|
|
|
the legacy variants. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The benchmark creates 1000+1 random UUIDs. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
MARKDOWN |
|
250
|
|
|
|
|
|
|
bench_code_template => 'my $uuid; UUID::generate_random($uuid) for 1..1000; UUID::generate_random($uuid); $uuid', |
|
251
|
|
|
|
|
|
|
features => { |
|
252
|
|
|
|
|
|
|
is_xs => 1, |
|
253
|
|
|
|
|
|
|
is_pp => 0, |
|
254
|
|
|
|
|
|
|
create_v1 => 0, |
|
255
|
|
|
|
|
|
|
create_v2 => 0, |
|
256
|
|
|
|
|
|
|
create_v3 => 0, |
|
257
|
|
|
|
|
|
|
create_v4 => 0, |
|
258
|
|
|
|
|
|
|
v4_secure_random => 0, |
|
259
|
|
|
|
|
|
|
v4_rfc4122 => 0, |
|
260
|
|
|
|
|
|
|
create_v5 => 0, |
|
261
|
|
|
|
|
|
|
create_legacy => 1, |
|
262
|
|
|
|
|
|
|
}, |
|
263
|
|
|
|
|
|
|
}, |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
], |
|
266
|
|
|
|
|
|
|
}; |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
1; |
|
269
|
|
|
|
|
|
|
# ABSTRACT: List of modules that can generate immutable universally unique identifier (UUIDs) |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
__END__ |