Rev 75 | Rev 82 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | daniel-mar | 1 | <?php |
2 | daniel-mar | 2 | |
31 | daniel-mar | 3 | /* |
4 | * UUID & MAC Utils |
||
5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
||
76 | daniel-mar | 6 | * Version 2023-11-10 |
31 | daniel-mar | 7 | * |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
9 | * you may not use this file except in compliance with the License. |
||
10 | * You may obtain a copy of the License at |
||
11 | * |
||
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
13 | * |
||
14 | * Unless required by applicable law or agreed to in writing, software |
||
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
17 | * See the License for the specific language governing permissions and |
||
18 | * limitations under the License. |
||
19 | */ |
||
20 | |||
21 | include_once __DIR__.'/includes/uuid_utils.inc.php'; |
||
22 | |||
72 | daniel-mar | 23 | const AUTO_NEW_UUIDS = 15; |
31 | daniel-mar | 24 | |
25 | ?><!DOCTYPE html> |
||
26 | <html lang="en"> |
||
27 | |||
2 | daniel-mar | 28 | <head> |
29 | <meta charset="iso-8859-1"> |
||
30 | <link rel="stylesheet" type="text/css" href="style.css"> |
||
31 | <title>UUID & MAC Utils by Daniel Marschall</title> |
||
35 | daniel-mar | 32 | <meta name=viewport content="width=device-width, initial-scale=1"> |
2 | daniel-mar | 33 | </head> |
34 | |||
35 | <body> |
||
36 | |||
25 | daniel-mar | 37 | <h1>UUID & MAC Utils by Daniel Marschall</h1> |
2 | daniel-mar | 38 | |
12 | daniel-mar | 39 | <p><a href="https://github.com/danielmarschall/uuid_mac_utils/">View the source code</a></p> |
2 | daniel-mar | 40 | |
31 | daniel-mar | 41 | <h2>Overview</h2> |
2 | daniel-mar | 42 | |
31 | daniel-mar | 43 | <ul> |
44 | <li><a href="#gen_uuid">Generate random and/or time-based UUIDs</a><ul> |
||
75 | daniel-mar | 45 | <li><a href="#gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch time-based (version 7) UUID</a></li> |
46 | <li><a href="#gen_uuidv6"><font color="green">New:</font> Generate reordered Gregorian time-based (version 6) UUID</a></li> |
||
31 | daniel-mar | 47 | <li><a href="#gen_uuidv4">Generate random (version 4) UUID</a></li> |
75 | daniel-mar | 48 | <li><a href="#gen_uuidv1">Generate Gregorian time-based (version 1) UUID</a></li> |
31 | daniel-mar | 49 | </ul></li> |
50 | <li><a href="#gen_other_uuid">Generate other UUID types</a><ul> |
||
53 | daniel-mar | 51 | <li><a href="#gen_uuid_ncs">NCS (variant 0) UUID</a></li> |
31 | daniel-mar | 52 | <li><a href="#gen_uuidv2">Generate DCE Security (version 2) UUID</a></li> |
61 | daniel-mar | 53 | <li><a href="#gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</a></li> |
54 | <li><a href="#gen_uuidv8"><font color="green">New:</font> Generate Custom (version 8) UUID</a></li> |
||
31 | daniel-mar | 55 | </ul></li> |
56 | <li><a href="#interpret_uuid">Interpret a UUID</a></li> |
||
41 | daniel-mar | 57 | <li><a href="#interpret_mac">Interpret a MAC address (MAC / EUI / ELI / SAI / AAI)</a><ul> |
58 | <li><a href="#gen_aai">Generate an AAI</a></li> |
||
59 | </ul></li> |
||
31 | daniel-mar | 60 | </ul> |
2 | daniel-mar | 61 | |
31 | daniel-mar | 62 | <h2 id="gen_uuid">Generate random and/or time-based UUIDs</h2> |
30 | daniel-mar | 63 | |
75 | daniel-mar | 64 | <h3 id="gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch time-based (version 7) UUID ⭐</h3> |
31 | daniel-mar | 65 | |
72 | daniel-mar | 66 | <p><i>A UUIDv7 measures time in the Unix Epoch with an accuracy |
67 | between 1ms and 245ns, depending on how many bits are spent for the timestamp (48-60 bits). |
||
68 | The rest of the UUID (62-74 bits) is filled with random data. |
||
69 | The timestamp is at the front of the UUID, therefore the UUIDs are monotonically increasing, |
||
75 | daniel-mar | 70 | which is good for using them in database indexes. |
71 | Since this UUID version does not contain a MAC address, it is also |
||
72 | daniel-mar | 72 | recommended due to the improved privacy.</i></p> |
31 | daniel-mar | 73 | |
35 | daniel-mar | 74 | <script> |
75 | function show_uuidv7_info() { |
||
76 | document.getElementById("uuidv7_info_button").style.display = "none"; |
||
77 | document.getElementById("uuidv7_info").style.display = "block"; |
||
78 | } |
||
79 | </script> |
||
62 | daniel-mar | 80 | <p><a id="uuidv7_info_button" href="javascript:show_uuidv7_info()">Show format</a> |
35 | daniel-mar | 81 | <pre id="uuidv7_info" style="display:none">Variant 1, Version 7 UUID: |
37 | daniel-mar | 82 | - 48 bit <abbr title="Count of 1ms intervals passed since 1 Jan 1970 00:00:00 GMT">Unix Time in milliseconds</abbr> |
35 | daniel-mar | 83 | - 4 bit Version (fix 0x7) |
70 | daniel-mar | 84 | - 12 bit Data |
35 | daniel-mar | 85 | - 2 bit Variant (fix 0b10) |
70 | daniel-mar | 86 | - 62 bit Data |
35 | daniel-mar | 87 | |
70 | daniel-mar | 88 | Structure of data (74 bits): |
89 | - OPTIONAL : Sub-millisecond timestamp fraction (0-12 bits) |
||
90 | - OPTIONAL : Carefully seeded counter |
||
91 | - Random generated bits for any remaining space |
||
92 | |||
93 | Time resolution for various sub-millisecond bits: |
||
31 | daniel-mar | 94 | <?php |
70 | daniel-mar | 95 | for ($num_ms_frac_bits=0; $num_ms_frac_bits<=12; $num_ms_frac_bits++) { |
96 | $resolution_ns = 1000000 / pow(2,$num_ms_frac_bits); |
||
97 | if ($resolution_ns >= 1000000) $resolution_ns_hf = ($resolution_ns/1000000)." ms"; |
||
98 | else if ($resolution_ns >= 1000) $resolution_ns_hf = ($resolution_ns/1000)." µs"; |
||
99 | else $resolution_ns_hf = "$resolution_ns ns"; |
||
100 | echo "$num_ms_frac_bits bits fraction = $resolution_ns_hf\n"; |
||
101 | } |
||
102 | ?> |
||
72 | daniel-mar | 103 | |
104 | This implementation outputs: |
||
105 | - 12 bits sub-millisecond timestamp (~245ns resolution) |
||
106 | - no counter |
||
107 | - 62 bits random data |
||
70 | daniel-mar | 108 | </pre></p> |
109 | |||
110 | <?php |
||
31 | daniel-mar | 111 | if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */ |
35 | daniel-mar | 112 | echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>'; |
31 | daniel-mar | 113 | |
114 | echo '<pre>'; |
||
70 | daniel-mar | 115 | for ($i=0; $i<AUTO_NEW_UUIDS; $i++) { |
31 | daniel-mar | 116 | $uuid = gen_uuid_v7(); |
117 | echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>'; |
||
118 | } |
||
119 | echo '</pre>'; |
||
120 | } |
||
121 | ?> |
||
122 | |||
2 | daniel-mar | 123 | <form method="GET" action="interprete_uuid.php"> |
31 | daniel-mar | 124 | <input type="hidden" name="version" value="7"> |
125 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID"> |
||
2 | daniel-mar | 126 | </form> |
127 | |||
75 | daniel-mar | 128 | <h3 id="gen_uuidv6"><font color="green">New:</font> Generate reordered Gregorian time-based (version 6) UUID ⏰</h3> |
2 | daniel-mar | 129 | |
31 | daniel-mar | 130 | <p><i>Like UUIDv1, this kind of UUID is made of the MAC address of the generating computer, |
131 | the time, and a clock sequence. However, the components in UUIDv6 are reordered (time is at the beginning), |
||
75 | daniel-mar | 132 | so that UUIDs are monotonically increasing, which is good for using them in database indexes.</i></p> |
2 | daniel-mar | 133 | |
35 | daniel-mar | 134 | <script> |
135 | function show_uuidv6_info() { |
||
136 | document.getElementById("uuidv6_info_button").style.display = "none"; |
||
137 | document.getElementById("uuidv6_info").style.display = "block"; |
||
138 | } |
||
139 | </script> |
||
62 | daniel-mar | 140 | <p><a id="uuidv6_info_button" href="javascript:show_uuidv6_info()">Show format</a> |
35 | daniel-mar | 141 | <pre id="uuidv6_info" style="display:none">Variant 1, Version 6 UUID: |
37 | daniel-mar | 142 | - 48 bit High <abbr title="Count of 100ns intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
35 | daniel-mar | 143 | - 4 bit Version (fix 0x6) |
37 | daniel-mar | 144 | - 12 bit Low <abbr title="Count of 100ns intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
35 | daniel-mar | 145 | - 2 bit Variant (fix 0b10) |
146 | - 6 bit Clock Sequence High |
||
147 | - 8 bit Clock Sequence Low |
||
148 | - 48 bit MAC Address</pre></p> |
||
149 | |||
31 | daniel-mar | 150 | <?php |
151 | if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */ |
||
35 | daniel-mar | 152 | echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>'; |
31 | daniel-mar | 153 | |
154 | echo '<pre>'; |
||
70 | daniel-mar | 155 | for ($i=0; $i<AUTO_NEW_UUIDS; $i++) { |
31 | daniel-mar | 156 | $uuid = gen_uuid_v6(); |
157 | echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>'; |
||
158 | } |
||
159 | echo '</pre>'; |
||
160 | } |
||
161 | ?> |
||
162 | |||
2 | daniel-mar | 163 | <form method="GET" action="interprete_uuid.php"> |
31 | daniel-mar | 164 | <input type="hidden" name="version" value="6"> |
165 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID"> |
||
30 | daniel-mar | 166 | </form> |
167 | |||
31 | daniel-mar | 168 | <h3 id="gen_uuidv4">Generate random (version 4) UUID 🎲</h3> |
30 | daniel-mar | 169 | |
35 | daniel-mar | 170 | <p><i>A UUIDv4 is made of 122 random bits. No other information is encoded in this kind of UUID.</i></p> |
30 | daniel-mar | 171 | |
35 | daniel-mar | 172 | <script> |
173 | function show_uuidv4_info() { |
||
174 | document.getElementById("uuidv4_info_button").style.display = "none"; |
||
175 | document.getElementById("uuidv4_info").style.display = "block"; |
||
176 | } |
||
177 | </script> |
||
62 | daniel-mar | 178 | <p><a id="uuidv4_info_button" href="javascript:show_uuidv4_info()">Show format</a> |
35 | daniel-mar | 179 | <pre id="uuidv4_info" style="display:none">Variant 1, Version 4 UUID: |
180 | - 48 bit Random High |
||
181 | - 4 bit Version (fix 0x4) |
||
182 | - 12 bit Random Mid |
||
183 | - 2 bit Variant (fix 0b10) |
||
184 | - 62 bit Random Low</pre></p> |
||
185 | |||
31 | daniel-mar | 186 | <?php |
187 | if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */ |
||
35 | daniel-mar | 188 | echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>'; |
31 | daniel-mar | 189 | |
190 | echo '<pre>'; |
||
70 | daniel-mar | 191 | for ($i=0; $i<AUTO_NEW_UUIDS; $i++) { |
31 | daniel-mar | 192 | $uuid = gen_uuid_v4(); |
193 | echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>'; |
||
194 | } |
||
195 | echo '</pre>'; |
||
196 | } |
||
197 | ?> |
||
198 | |||
30 | daniel-mar | 199 | <form method="GET" action="interprete_uuid.php"> |
31 | daniel-mar | 200 | <input type="hidden" name="version" value="4"> |
201 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID"> |
||
30 | daniel-mar | 202 | </form> |
203 | |||
75 | daniel-mar | 204 | <h3 id="gen_uuidv1">Generate Gregorian time-based (version 1) UUID ⏰</h3> |
30 | daniel-mar | 205 | |
31 | daniel-mar | 206 | <p><i>A UUIDv1 is made of the MAC address of the generating computer, |
207 | the time, and a clock sequence.</i></p> |
||
30 | daniel-mar | 208 | |
35 | daniel-mar | 209 | <script> |
210 | function show_uuidv1_info() { |
||
211 | document.getElementById("uuidv1_info_button").style.display = "none"; |
||
212 | document.getElementById("uuidv1_info").style.display = "block"; |
||
213 | } |
||
214 | </script> |
||
62 | daniel-mar | 215 | <p><a id="uuidv1_info_button" href="javascript:show_uuidv1_info()">Show format</a> |
35 | daniel-mar | 216 | <pre id="uuidv1_info" style="display:none">Variant 1, Version 1 UUID: |
37 | daniel-mar | 217 | - 32 bit Low <abbr title="Count of 100ns intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
218 | - 16 bit Mid <abbr title="Count of 100ns intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
||
35 | daniel-mar | 219 | - 4 bit Version (fix 0x1) |
37 | daniel-mar | 220 | - 12 bit High <abbr title="Count of 100ns intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
35 | daniel-mar | 221 | - 2 bit Variant (fix 0b10) |
222 | - 6 bit Clock Sequence High |
||
223 | - 8 bit Clock Sequence Low |
||
224 | - 48 bit MAC Address</pre></p> |
||
225 | |||
31 | daniel-mar | 226 | <?php |
227 | if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */ |
||
35 | daniel-mar | 228 | echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>'; |
31 | daniel-mar | 229 | |
230 | echo '<pre>'; |
||
70 | daniel-mar | 231 | for ($i=0; $i<AUTO_NEW_UUIDS; $i++) { |
31 | daniel-mar | 232 | $uuid = gen_uuid_v1(); |
233 | echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>'; |
||
234 | } |
||
235 | echo '</pre>'; |
||
236 | } |
||
237 | ?> |
||
238 | |||
30 | daniel-mar | 239 | <form method="GET" action="interprete_uuid.php"> |
31 | daniel-mar | 240 | <input type="hidden" name="version" value="1"> |
241 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID"> |
||
30 | daniel-mar | 242 | </form> |
243 | |||
31 | daniel-mar | 244 | <h2 id="gen_other_uuid">Generate other UUID types</h2> |
30 | daniel-mar | 245 | |
47 | daniel-mar | 246 | <p><i>The following types of UUIDs are less common and/or require special knowledge. Please only use the following |
30 | daniel-mar | 247 | generators if you know what you are doing.</i></p> |
248 | |||
53 | daniel-mar | 249 | <h3 id="gen_uuid_ncs">NCS (variant 0) UUID</h3> |
30 | daniel-mar | 250 | |
53 | daniel-mar | 251 | <p>The <abbr title="Network Computing System">NCS</abbr> UUIDs are a legacy format |
252 | initially designed by Apollo Computer that cannot be generated anymore, because the |
||
30 | daniel-mar | 253 | amount of available timestamp bits was exhausted on <strong>5 September 2015</strong>. |
53 | daniel-mar | 254 | As an example, here is the last possible NCS UUID (all bits of the timestamp are set to 1) for IP address 127.0.0.1: |
34 | daniel-mar | 255 | <a href="interprete_uuid.php?uuid=ffffffff-ffff-0000-027f-000001000000"><code>ffffffff-ffff-0000-027f-000001000000</code></a>.</p> |
30 | daniel-mar | 256 | |
35 | daniel-mar | 257 | <script> |
258 | function show_uuidnce_info() { |
||
259 | document.getElementById("uuidnce_info_button").style.display = "none"; |
||
260 | document.getElementById("uuidnce_info").style.display = "block"; |
||
261 | } |
||
262 | </script> |
||
62 | daniel-mar | 263 | <p><a id="uuidnce_info_button" href="javascript:show_uuidnce_info()">Show format</a> |
35 | daniel-mar | 264 | <pre id="uuidnce_info" style="display:none">Variant 0 UUID: |
37 | daniel-mar | 265 | - 32 bit High <abbr title="Count of 4µs intervals passed since 1 Jan 1980 00:00:00 GMT">Time</abbr> |
266 | - 16 bit Low <abbr title="Count of 4µs intervals passed since 1 Jan 1980 00:00:00 GMT">Time</abbr> |
||
35 | daniel-mar | 267 | - 16 bit Reserved |
268 | - 1 bit Variant (fix 0b0) |
||
37 | daniel-mar | 269 | - 7 bit <abbr title="socket_$unspec (0x0) |
270 | socket_$unix (0x1) |
||
271 | socket_$internet (0x2) |
||
272 | socket_$implink (0x3) |
||
273 | socket_$pup (0x4) |
||
274 | socket_$chaos (0x5) |
||
275 | socket_$ns (0x6) |
||
276 | socket_$nbs (0x7) |
||
277 | socket_$ecma (0x8) |
||
278 | socket_$datakit (0x9) |
||
279 | socket_$ccitt (0xA) |
||
280 | socket_$sna (0xB) |
||
281 | socket_$unspec2 (0xC) |
||
282 | socket_$dds (0xD)">Family</abbr> |
||
35 | daniel-mar | 283 | - 56 bit Node</pre></p> |
284 | |||
31 | daniel-mar | 285 | <h3 id="gen_uuidv2">Generate DCE Security (version 2) UUID</h3> |
30 | daniel-mar | 286 | |
37 | daniel-mar | 287 | <p><i>An UUIDv2 contains information about the creator (person, group, or organization), the generating system (MAC address), and time. |
35 | daniel-mar | 288 | The creator information replaced parts of the time bits, therefore the time resolution is very low.</i></p> |
289 | |||
290 | <script> |
||
291 | function show_uuidv2_info() { |
||
292 | document.getElementById("uuidv2_info_button").style.display = "none"; |
||
293 | document.getElementById("uuidv2_info").style.display = "block"; |
||
294 | } |
||
295 | </script> |
||
62 | daniel-mar | 296 | <p><a id="uuidv2_info_button" href="javascript:show_uuidv2_info()">Show format</a> |
35 | daniel-mar | 297 | <pre id="uuidv2_info" style="display:none">Variant 1, Version 2 UUID: |
298 | - 32 bit Local Domain Number |
||
37 | daniel-mar | 299 | - 16 bit Mid <abbr title="Count of 429.4967296s intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
35 | daniel-mar | 300 | - 4 bit Version (fix 0x2) |
37 | daniel-mar | 301 | - 12 bit High <abbr title="Count of 429.4967296s intervals passed since 15 Oct 1582 00:00:00 GMT">Time</abbr> |
35 | daniel-mar | 302 | - 2 bit Variant (fix 0b10) |
303 | - 6 bit Clock Sequence |
||
37 | daniel-mar | 304 | - 8 bit <abbr title="0 = person |
305 | 1 = group |
||
306 | 2 = org |
||
307 | 3-255 = site-defined">Local Domain</abbr> |
||
35 | daniel-mar | 308 | - 48 bit MAC Address</pre></p> |
309 | |||
30 | daniel-mar | 310 | <form method="GET" action="interprete_uuid.php"> |
2 | daniel-mar | 311 | <input type="hidden" name="version" value="2"> |
35 | daniel-mar | 312 | <label>Domain (8 bits):</label><select name="domain_choose" id="dce_domain_choice" onchange="javascript:dce_domain_choose();"> |
34 | daniel-mar | 313 | <option value="uid">Person (e.g. POSIX UID)</option> |
314 | <option value="gid">Group (e.g. POSIX GID)</option> |
||
315 | <option value="org">Organization</option> |
||
2 | daniel-mar | 316 | <option value="site">Site-defined</option> |
62 | daniel-mar | 317 | </select> = Address Family ID: <input type="number" min="0" max="255" name="dce_domain" value="" id="dce_domain" style="width:50px" pattern="[0-9]+"> (decimal notation)<br> |
35 | daniel-mar | 318 | <label>Value (32 bits):</label><input type="number" min="0" max="4294967295" name="dce_id" value="0" id="dce_id" style="width:200px" pattern="[0-9]+"> (decimal notation)<br> |
37 | daniel-mar | 319 | <font color="red">Warning</font>: The timestamp has an accuracy of 7:10 minutes, |
30 | daniel-mar | 320 | therefore the uniqueness of these UUIDs is not guaranteed!<br><br> |
59 | daniel-mar | 321 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create UUIDv2"> |
2 | daniel-mar | 322 | </form> |
323 | <script> |
||
324 | function dce_domain_choose() { |
||
325 | var ns = document.getElementById('dce_domain_choice').value; |
||
326 | if (ns == "uid") { |
||
327 | document.getElementById('dce_domain').value = "0"; |
||
328 | } |
||
329 | if (ns == "gid") { |
||
330 | document.getElementById('dce_domain').value = "1"; |
||
331 | } |
||
332 | if (ns == "org") { |
||
333 | document.getElementById('dce_domain').value = "2"; |
||
334 | } |
||
335 | if (ns == "site") { |
||
336 | document.getElementById('dce_domain').value = ""; |
||
337 | } |
||
338 | } |
||
339 | dce_domain_choose(); |
||
340 | </script> |
||
341 | |||
61 | daniel-mar | 342 | <h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3> |
2 | daniel-mar | 343 | |
57 | daniel-mar | 344 | <p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash. |
345 | The revision of RFC4122 also contains an example for a custom UUIDv8 that |
||
72 | daniel-mar | 346 | uses modern hash algorithms.</i></p> |
35 | daniel-mar | 347 | |
348 | <script> |
||
349 | function show_uuidv35_info() { |
||
350 | document.getElementById("uuidv35_info_button").style.display = "none"; |
||
351 | document.getElementById("uuidv35_info").style.display = "block"; |
||
352 | } |
||
353 | </script> |
||
62 | daniel-mar | 354 | <p><a id="uuidv35_info_button" href="javascript:show_uuidv35_info()">Show format</a> |
58 | daniel-mar | 355 | <pre id="uuidv35_info" style="display:none">Variant 1, Version 3/5/8 UUID: |
35 | daniel-mar | 356 | - 48 bit Hash High |
58 | daniel-mar | 357 | - 4 bit Version (fix 0x3, 0x5, or 0x8) |
35 | daniel-mar | 358 | - 12 bit Hash Mid |
359 | - 2 bit Variant (fix 0b10) |
||
62 | daniel-mar | 360 | - 62 bit Hash Low |
35 | daniel-mar | 361 | |
62 | daniel-mar | 362 | |
75 | daniel-mar | 363 | <u>As shown in <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">draft-ietf-uuidrev-rfc4122bis-12</a> Appendix C.2:</u> |
69 | daniel-mar | 364 | UUIDv8(<i>HashAlgo</i>, <i>NameSpaceUuid</i>, <i>Data</i>) := <abbr title="Adds UUID variant 0b10 and version 8">ConvertRawBytesToUuid_v8</abbr>(<i>HashAlgo</i>( Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )). |
67 | daniel-mar | 365 | |
62 | daniel-mar | 366 | </pre></p> |
367 | |||
35 | daniel-mar | 368 | <style> |
369 | label { |
||
370 | width:120px; |
||
371 | text-align:left; |
||
372 | margin-right: 20px; |
||
373 | display:inline-block; |
||
374 | } |
||
375 | </style> |
||
376 | |||
2 | daniel-mar | 377 | <form method="GET" action="interprete_uuid.php"> |
59 | daniel-mar | 378 | <label>Hash algorithm:</label><select name="version" id="nb_version" onchange="javascript:nb_version_choose();"> |
379 | <?php |
||
67 | daniel-mar | 380 | |
75 | daniel-mar | 381 | echo "\t\t<option disabled>--- UUIDv3 (defined in RFC 4122) ---</option>\n"; |
67 | daniel-mar | 382 | echo "\t\t<option value=\"3\">MD5</option>\n"; |
75 | daniel-mar | 383 | echo "\t\t<option disabled>--- UUIDv5 (defined in RFC 4122) ---</option>\n"; |
67 | daniel-mar | 384 | echo "\t\t<option value=\"5\" selected>SHA1</option>\n"; |
75 | daniel-mar | 385 | echo "\t\t<option disabled>--- UUIDv8 (shown in Internet Draft 12, Appendix C.2) ---</option>\n"; |
69 | daniel-mar | 386 | $tmp = []; |
387 | $algos = hash_algos(); |
||
388 | $algos[] = 'shake128'; |
||
389 | $algos[] = 'shake256'; |
||
390 | foreach ($algos as $algo) { |
||
391 | if ($algo == 'md5') continue; // use UUIDv3 instead |
||
392 | if ($algo == 'sha1') continue; // use UUIDv5 instead |
||
393 | $friendlyName = strtoupper($algo); |
||
394 | |||
395 | if ($algo == 'shake128') $bits = 999; |
||
396 | else if ($algo == 'shake256') $bits = 999; |
||
397 | else $bits = strlen(hash($algo, '', true)) * 8; |
||
75 | daniel-mar | 398 | if ($bits < 128) $friendlyName .= " (Small hash size! $bits bits)"; // <-- this is not described in Appendix C.2 |
69 | daniel-mar | 399 | |
400 | $space = $algo; |
||
401 | $tmp[$friendlyName] = '<option value="8_namebased_'.$space.'">'.htmlentities($friendlyName).'</option>'; |
||
402 | } |
||
403 | natsort($tmp); |
||
404 | foreach ($tmp as $html) { |
||
405 | echo "\t\t$html\n"; |
||
406 | } |
||
407 | |||
59 | daniel-mar | 408 | ?> |
75 | daniel-mar | 409 | </select><br> |
35 | daniel-mar | 410 | <label>Namespace:</label><select name="namespace_choose" id="nb_nsc" onchange="javascript:nb_ns_choose();"> |
2 | daniel-mar | 411 | <option value="dns">DNS</option> |
412 | <option value="url">URL</option> |
||
413 | <option value="oid">OID</option> |
||
414 | <option value="x500">X.500 DN</option> |
||
76 | daniel-mar | 415 | <option value="r74n">R74n Namespace</option> |
35 | daniel-mar | 416 | <!-- <option value="oidplus_ns">OIDplus ns only</option> --> |
417 | <!-- <option value="oidplus_ns_val">OIDplus ns+val</option> --> |
||
28 | daniel-mar | 418 | <!-- <option value="oidplus_pubkey">OIDplus pubkey</option> --> |
2 | daniel-mar | 419 | <option value="other">Other</option> |
59 | daniel-mar | 420 | </select> = Namespace UUID: <input type="text" name="nb_ns" value="" id="nb_ns" style="width:270px" onchange="javascript:nb_ns_textchange();" pattern="[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}"><br> |
35 | daniel-mar | 421 | <label>Value:</label><input type="text" name="nb_val" value="" id="nb_val" style="width:300px"><br> |
30 | daniel-mar | 422 | <font color="red">Warning</font>: These UUIDs do not contain a timestamp, |
423 | therefore the uniqueness of these UUIDs is not guaranteed!<br><br> |
||
59 | daniel-mar | 424 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" id="nb_create_btn" value="Create UUID"> |
2 | daniel-mar | 425 | </form> |
426 | <script> |
||
59 | daniel-mar | 427 | function nb_version_choose() { |
428 | var ver = document.getElementById('nb_version').value; |
||
429 | document.getElementById('nb_create_btn').value = 'Create UUIDv' + ver.substr(0,1); |
||
430 | } |
||
35 | daniel-mar | 431 | function nb_ns_textchange() { |
432 | var ns = document.getElementById('nb_ns').value.toLowerCase(); |
||
433 | if (ns == "6ba7b810-9dad-11d1-80b4-00c04fd430c8") { |
||
434 | if (document.getElementById('nb_nsc').value != "dns") { |
||
435 | document.getElementById('nb_nsc').value = "dns"; |
||
57 | daniel-mar | 436 | document.getElementById('nb_val').value = "www.example.com"; |
35 | daniel-mar | 437 | } |
438 | } |
||
439 | else if (ns == "6ba7b811-9dad-11d1-80b4-00c04fd430c8") { |
||
440 | if (document.getElementById('nb_nsc').value != "url") { |
||
441 | document.getElementById('nb_nsc').value = "url"; |
||
57 | daniel-mar | 442 | document.getElementById('nb_val').value = "http://www.example.com/"; |
35 | daniel-mar | 443 | } |
444 | } |
||
445 | else if (ns == "6ba7b812-9dad-11d1-80b4-00c04fd430c8") { |
||
446 | if (document.getElementById('nb_nsc').value != "oid") { |
||
447 | document.getElementById('nb_nsc').value = "oid"; |
||
448 | document.getElementById('nb_val').value = "2.999"; |
||
449 | } |
||
450 | } |
||
451 | else if (ns == "6ba7b814-9dad-11d1-80b4-00c04fd430c8") { |
||
452 | if (document.getElementById('nb_nsc').value != "x500") { |
||
453 | document.getElementById('nb_nsc').value = "x500"; |
||
454 | document.getElementById('nb_val').value = "UID=jsmith,DC=example,DC=net"; |
||
455 | } |
||
456 | } |
||
76 | daniel-mar | 457 | else if (ns == "ca069732-780c-11ee-b962-000000000074") { // https://r74n.com/id/uuid |
458 | if (document.getElementById('nb_nsc').value != "r74n") { |
||
459 | document.getElementById('nb_nsc').value = "r74n"; |
||
460 | document.getElementById('nb_val').value = "ants"; |
||
461 | } |
||
462 | } |
||
35 | daniel-mar | 463 | else { |
464 | if (document.getElementById('nb_nsc').value != "other") { |
||
465 | document.getElementById('nb_nsc').value = "other"; |
||
466 | document.getElementById('nb_val').value = ""; |
||
467 | } |
||
468 | } |
||
469 | } |
||
2 | daniel-mar | 470 | function nb_ns_choose() { |
471 | var ns = document.getElementById('nb_nsc').value; |
||
472 | if (ns == "dns") { |
||
473 | document.getElementById('nb_ns').value = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"; |
||
57 | daniel-mar | 474 | document.getElementById('nb_val').value = "www.example.com"; |
2 | daniel-mar | 475 | } |
35 | daniel-mar | 476 | else if (ns == "url") { |
2 | daniel-mar | 477 | document.getElementById('nb_ns').value = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"; |
57 | daniel-mar | 478 | document.getElementById('nb_val').value = "http://www.example.com/"; |
2 | daniel-mar | 479 | } |
35 | daniel-mar | 480 | else if (ns == "oid") { |
2 | daniel-mar | 481 | document.getElementById('nb_ns').value = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"; |
482 | document.getElementById('nb_val').value = "2.999"; |
||
483 | } |
||
35 | daniel-mar | 484 | else if (ns == "x500") { |
2 | daniel-mar | 485 | document.getElementById('nb_ns').value = "6ba7b814-9dad-11d1-80b4-00c04fd430c8"; |
486 | document.getElementById('nb_val').value = "UID=jsmith,DC=example,DC=net"; |
||
487 | } |
||
76 | daniel-mar | 488 | else if (ns == "r74n") { // https://r74n.com/id/uuid |
489 | document.getElementById('nb_ns').value = "ca069732-780c-11ee-b962-000000000074"; |
||
490 | document.getElementById('nb_val').value = "ants"; |
||
491 | } |
||
35 | daniel-mar | 492 | /* |
493 | else if (ns == "oidplus_ns") { |
||
2 | daniel-mar | 494 | document.getElementById('nb_ns').value = "0943e3ce-4b79-11e5-b742-78e3b5fc7f22"; |
495 | document.getElementById('nb_val').value = "ipv4"; |
||
496 | } |
||
35 | daniel-mar | 497 | else if (ns == "oidplus_ns_val") { |
2 | daniel-mar | 498 | document.getElementById('nb_ns').value = "ad1654e6-7e15-11e4-9ef6-78e3b5fc7f22"; |
499 | document.getElementById('nb_val').value = "ipv4:8.8.8.8"; |
||
500 | } |
||
35 | daniel-mar | 501 | else if (ns == "oidplus_ns_pubkey") { |
28 | daniel-mar | 502 | document.getElementById('nb_ns').value = "fd16965c-8bab-11ed-8744-3c4a92df8582"; |
31 | daniel-mar | 503 | document.getElementById('nb_val').value = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqg/PnsC1WX3C1/mUSLuk0DIaDHtEsxBnG0auYJRJ1hBtbUUvItbK0odlKrX2SFo1MJJpu/SSxTzAgqkKZsZe3cCFkgA1svfuH9i94oGLjJ4n0kRJEGlanCmGndJBfIqGDJaQE2BJ8tLxeBrpkd9l0KvJsjhRmqJAb9KYK3KYFsWvT+wyjD3UJ1eHcgLbF/Qb3cwMU/u7Fs7ZpsNMW4phDPlsYsk9XHFpJ1/UCj6G53mYRfOC/ouDdGShlbVLB15s0V95QpnU/7lL8mJ2lE+sTZekGNBA4XbJv2gs21cR4E8zc/z+NyZS7117DYZoJqrAN8sKz6xGoKgQF6wueCK5qQIDAQAB"; |
28 | daniel-mar | 504 | } |
505 | */ |
||
35 | daniel-mar | 506 | else if (ns == "other") { |
2 | daniel-mar | 507 | document.getElementById('nb_ns').value = ""; |
508 | document.getElementById('nb_val').value = ""; |
||
509 | } |
||
510 | } |
||
59 | daniel-mar | 511 | nb_version_choose(); |
2 | daniel-mar | 512 | nb_ns_choose(); |
513 | </script> |
||
514 | |||
61 | daniel-mar | 515 | <h3 id="gen_uuidv8"><font color="green">New:</font> Generate Custom (version 8) UUID</h3> |
34 | daniel-mar | 516 | |
37 | daniel-mar | 517 | <p><i>UUIDv8 is made of 122 bits application-specific / custom data. The other 6 bits are used to specify the variant and version of the UUID, to make it RFC-compatible.</i></p> |
35 | daniel-mar | 518 | |
519 | <script> |
||
520 | function show_uuidv8_info() { |
||
521 | document.getElementById("uuidv8_info_button").style.display = "none"; |
||
522 | document.getElementById("uuidv8_info").style.display = "block"; |
||
523 | } |
||
65 | daniel-mar | 524 | function uuidv8_changedec(block, len) { |
525 | var x = document.getElementById("v8_block"+block+"_dec").value; |
||
526 | if (x.trim() == "") x = 0; |
||
527 | x = parseInt(x); |
||
528 | if (isNaN(x)) { |
||
529 | x = "???"; |
||
530 | } else { |
||
531 | x = x.toString(16).padStart(len, '0'); |
||
532 | if ((len > 0) && (x.length > len)) x = "Overflow"; |
||
533 | } |
||
534 | document.getElementById("v8_block"+block+"_hex").value = x; |
||
535 | } |
||
536 | function uuidv8_changehex(block, len) { |
||
537 | var x = document.getElementById("v8_block"+block+"_hex").value; |
||
538 | if (x.trim() == "") x = 0; |
||
539 | x = parseInt(x, 16); |
||
540 | if (isNaN(x)) { |
||
541 | x = "???"; |
||
542 | } else { |
||
543 | x = x.toString().padStart(len, '0'); |
||
544 | if ((len > 0) && (x.length > len)) x = "Overflow"; // Note: For block 3/4, the overflow actually happens at 12/14 bits, not at 4 nibbles (16 bits) |
||
545 | } |
||
546 | document.getElementById("v8_block"+block+"_dec").value = x; |
||
547 | } |
||
35 | daniel-mar | 548 | </script> |
62 | daniel-mar | 549 | <p><a id="uuidv8_info_button" href="javascript:show_uuidv8_info()">Show format</a> |
35 | daniel-mar | 550 | <pre id="uuidv8_info" style="display:none">Variant 1, Version 8 UUID: |
63 | daniel-mar | 551 | - 48 bit Custom data [Block 1+2] |
35 | daniel-mar | 552 | - 4 bit Version (fix 0x8) |
63 | daniel-mar | 553 | - 12 bit Custom data [Block 3] |
35 | daniel-mar | 554 | - 2 bit Variant (fix 0b10) |
63 | daniel-mar | 555 | - 62 bit Custom data [Block 4+5]</pre></p> |
35 | daniel-mar | 556 | |
34 | daniel-mar | 557 | <form method="GET" action="interprete_uuid.php"> |
558 | <input type="hidden" name="version" value="8"> |
||
65 | daniel-mar | 559 | |
560 | <label>Block 1 (32 bits):</label>0x<input type="text" name="block1" value="00000000" maxlength="8" id="v8_block1_hex" onkeyup="uuidv8_changehex(1, 0)" style="width:150px" pattern="[0-9a-fA-F]+"> = Decimal |
||
561 | <input type="number" name="block1dec" value="0" min="0" maxlength="20" id="v8_block1_dec" onmouseup="uuidv8_changedec(1, 8)" onkeyup="uuidv8_changedec(1, 8)" style="width:150px"><br> |
||
562 | |||
563 | <label>Block 2 (16 bits):</label>0x<input type="text" name="block2" value="0000" maxlength="4" id="v8_block2_hex" onkeyup="uuidv8_changehex(2, 0)" style="width:150px" pattern="[0-9a-fA-F]+"> = Decimal |
||
564 | <input type="number" name="block2dec" value="0" min="0" maxlength="20" id="v8_block2_dec" onmouseup="uuidv8_changedec(2, 4)" onkeyup="uuidv8_changedec(2, 4)" style="width:150px"><br> |
||
565 | |||
566 | <label>Block 3 (<abbr title="The high 4 bits are occupied by the UUID version = 8">12 bits</abbr>):</label>0x<input type="text" name="block3" value="0000" maxlength="4" id="v8_block3_hex" onkeyup="uuidv8_changehex(3, 0)" style="width:150px" pattern="[0-9a-fA-F]+"> = Decimal |
||
567 | <input type="number" name="block3dec" value="0" min="0" maxlength="20" id="v8_block3_dec" onmouseup="uuidv8_changedec(3, 4)" onkeyup="uuidv8_changedec(3, 4)" style="width:150px"><br> |
||
568 | |||
569 | <label>Block 4 (<abbr title="The high 2 bits are occupied by the UUID variant = 0b10">14 bits</abbr>):</label>0x<input type="text" name="block4" value="0000" maxlength="4" id="v8_block4_hex" onkeyup="uuidv8_changehex(4, 0)" style="width:150px" pattern="[0-9a-fA-F]+"> = Decimal |
||
570 | <input type="number" name="block4dec" value="0" min="0" maxlength="20" id="v8_block4_dec" onmouseup="uuidv8_changedec(4, 4)" onkeyup="uuidv8_changedec(4, 4)" style="width:150px"><br> |
||
571 | |||
572 | <label>Block 5 (48 bits):</label>0x<input type="text" name="block5" value="000000000000" maxlength="12" id="v8_block5_hex" onkeyup="uuidv8_changehex(5, 0)" style="width:150px" pattern="[0-9a-fA-F]+"> = Decimal |
||
573 | <input type="number" name="block5dec" value="0" min="0" maxlength="20" id="v8_block5_dec" onmouseup="uuidv8_changedec(5, 12)" onkeyup="uuidv8_changedec(5, 12)" style="width:150px"><br> |
||
574 | |||
34 | daniel-mar | 575 | <font color="red">Warning</font>: These UUIDs do not contain a timestamp, |
576 | therefore the uniqueness of these UUIDs is not guaranteed!<br><br> |
||
59 | daniel-mar | 577 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create UUIDv8"> |
34 | daniel-mar | 578 | </form> |
579 | |||
31 | daniel-mar | 580 | <h2 id="interpret_uuid">Interpret a UUID</h2> |
2 | daniel-mar | 581 | |
30 | daniel-mar | 582 | <p>You can enter a UUID in the following notations:</p> |
2 | daniel-mar | 583 | |
584 | <ul> |
||
585 | <li>Classic notation (case insensitive, curly braces optional): <code>9e83839a-5967-11e4-8c1c-78e3b5fc7f22</code></li> |
||
586 | <li>As OID: <code>2.25.210700883446948645633376489934419689250</code></li> |
||
587 | </ul> |
||
588 | |||
589 | <p>The script will output:</p> |
||
590 | |||
591 | <ul> |
||
592 | <li>Notation as UUID and OID</li> |
||
35 | daniel-mar | 593 | <li>Version, variant, and additional data (date and time, clock sequence, node id, etc.)</li> |
2 | daniel-mar | 594 | </ul> |
595 | |||
30 | daniel-mar | 596 | <p>Please enter a UUID or UUID OID:</p> |
2 | daniel-mar | 597 | |
598 | <form method="GET" action="interprete_uuid.php"> |
||
32 | daniel-mar | 599 | <input type="text" name="uuid" value="" style="width:300px"> <input type="submit" value="Interprete"> |
2 | daniel-mar | 600 | </form> |
601 | |||
31 | daniel-mar | 602 | <h2 id="interpret_mac">Interpret a MAC address (<abbr title="Media Access Control">MAC</abbr> / |
26 | daniel-mar | 603 | <abbr title="Extended Unique Identifier">EUI</abbr> / |
604 | <abbr title="Extended Local Identifier">ELI</abbr> / |
||
605 | <abbr title="Standard Assigned Identifier">SAI</abbr> / |
||
606 | <abbr title="Administratively Assigned Identifier">AAI</abbr>)</h2> |
||
2 | daniel-mar | 607 | |
30 | daniel-mar | 608 | <p>You can enter a UUID in the following notations:</p> |
2 | daniel-mar | 609 | |
610 | <ul> |
||
611 | <li><code>AA-BB-CC-DD-EE-FF</code></li> |
||
612 | <li><code>AA:BB:CC:DD:EE:FF</code></li> |
||
613 | <li><code>AABBCC.DDEEFF</code> (case insensitive)</li> |
||
16 | daniel-mar | 614 | <li><code>AA-BB-CC-DD-EE-FF-11-22</code> (EUI-64)</li> |
615 | <li><code>AA:BB:CC:DD:EE:FF-11-22</code> (EUI-64)</li> |
||
616 | <li><code>fe80::1322:33ff:fe44:5566</code> (IPv6 Link Local / EUI-64)</li> |
||
2 | daniel-mar | 617 | </ul> |
618 | |||
619 | <p>The script will output:</p> |
||
620 | |||
621 | <ul> |
||
622 | <li>Information about the I/G and U/L flags.</li> |
||
623 | <li>Information about the entry in the IEEE registry, if available.</li> |
||
624 | <li>Information about the registrant, if available.</li> |
||
625 | </ul> |
||
626 | |||
29 | daniel-mar | 627 | <p>Please enter a MAC (EUI, ELI, SAI, AAI), or IPv6-Link-Local address:</p> |
2 | daniel-mar | 628 | |
629 | <form method="GET" action="interprete_mac.php"> |
||
32 | daniel-mar | 630 | <input type="text" name="mac" value="" style="width:250px"> <input type="submit" value="Interprete"> |
2 | daniel-mar | 631 | </form> |
632 | |||
62 | daniel-mar | 633 | <h3 id="gen_aai">Generate an <abbr title="Administratively Assigned Identifier">AAI</abbr></h3> |
41 | daniel-mar | 634 | |
635 | <p><i>An Administratively Assigned Identifier (AAI) is a MAC address which can be locally defined |
||
636 | by applications or an administrator. Unlike the EUI, an AAI is NOT worldwide unique.</i></p> |
||
637 | |||
638 | <form method="GET" action="interprete_mac.php"> |
||
639 | <input type="hidden" name="aai_gen" value="1"> |
||
640 | <input type="hidden" name="aai_gen_bits" value="48"> |
||
641 | <input type="hidden" name="aai_gen_multicast" value="0"> |
||
642 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Generate AAI-48"> |
||
643 | </form> |
||
644 | |||
645 | <br> |
||
646 | |||
647 | <form method="GET" action="interprete_mac.php"> |
||
648 | <input type="hidden" name="aai_gen" value="1"> |
||
649 | <input type="hidden" name="aai_gen_bits" value="64"> |
||
650 | <input type="hidden" name="aai_gen_multicast" value="0"> |
||
651 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Generate AAI-64"> |
||
652 | </form> |
||
653 | |||
654 | <p>The following options are rather unusual, but are implemented for the sake of completeness:</p> |
||
655 | |||
656 | <form method="GET" action="interprete_mac.php"> |
||
657 | <input type="hidden" name="aai_gen" value="1"> |
||
658 | <input type="hidden" name="aai_gen_bits" value="48"> |
||
659 | <input type="hidden" name="aai_gen_multicast" value="1"> |
||
660 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Generate Multicast AAI-48"> |
||
661 | </form> |
||
662 | |||
663 | <br> |
||
664 | |||
665 | <form method="GET" action="interprete_mac.php"> |
||
666 | <input type="hidden" name="aai_gen" value="1"> |
||
667 | <input type="hidden" name="aai_gen_bits" value="64"> |
||
668 | <input type="hidden" name="aai_gen_multicast" value="1"> |
||
669 | <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Generate Multicast AAI-64"> |
||
670 | </form> |
||
671 | |||
22 | daniel-mar | 672 | <br><br><br> |
673 | |||
2 | daniel-mar | 674 | </body> |
675 | |||
676 | </html> |