Subversion Repositories uuid_mac_utils

Rev

Rev 30 | Rev 32 | 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
6
* Version 2023-07-11
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
 
23
const AUTO_NEW_UUIDS = 10;
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 &amp; MAC Utils by Daniel Marschall</title>
32
</head>
33
 
34
<body>
35
 
25 daniel-mar 36
<h1>UUID &amp; MAC Utils by Daniel Marschall</h1>
2 daniel-mar 37
 
12 daniel-mar 38
<p><a href="https://github.com/danielmarschall/uuid_mac_utils/">View the source code</a></p>
2 daniel-mar 39
 
31 daniel-mar 40
<h2>Overview</h2>
2 daniel-mar 41
 
31 daniel-mar 42
<ul>
43
    <li><a href="#gen_uuid">Generate random and/or time-based UUIDs</a><ul>
44
            <li><a href="#gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch Time (version 7) UUID</a></li>
45
            <li><a href="#gen_uuidv6"><font color="green">New:</font> Generate reordered time-based (version 6) UUID</a></li>
46
            <li><a href="#gen_uuidv4">Generate random (version 4) UUID</a></li>
47
            <li><a href="#gen_uuidv1">Generate time-based (version 1) UUID</a></li>
48
        </ul></li>
49
    <li><a href="#gen_other_uuid">Generate other UUID types</a><ul>
50
            <li><a href="#gen_uuid_nce">NCE (variant 0) UUID</a></li>
51
            <li><a href="#gen_uuidv2">Generate DCE Security (version 2) UUID</a></li>
52
            <li><a href="#gen_uuidv35">Generate name-based (version 3/5) UUID</a></li>
53
        </ul></li>
54
    <li><a href="#interpret_uuid">Interpret a UUID</a></li>
55
    <li><a href="#interpret_mac">Interpret a MAC address (MAC / EUI / ELI / SAI / AAI)</a></li>
56
</ul>
2 daniel-mar 57
 
31 daniel-mar 58
<h2 id="gen_uuid">Generate random and/or time-based UUIDs</h2>
30 daniel-mar 59
 
31 daniel-mar 60
<h3 id="gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch Time (version 7) UUID &#11088</h3>
61
 
62
<p><i>A UUIDv7 is made of time and 74 random bits.
63
        Since the time is at the beginning, the UUIDs are monotonically increasing.
64
        Due to the missing MAC address, this UUID version is recommended due to
65
        improved privacy.</i></p>
66
 
67
<?php
68
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
69
        echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs which were created just for you! (Reload the page to get more)</p>';
70
 
71
        echo '<pre>';
72
        for ($i=0; $i<10; $i++) {
73
                $uuid = gen_uuid_v7();
74
                echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>';
75
        }
76
        echo '</pre>';
77
}
78
?>
79
 
2 daniel-mar 80
<form method="GET" action="interprete_uuid.php">
31 daniel-mar 81
    <input type="hidden" name="version" value="7">
82
    <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID">
2 daniel-mar 83
</form>
84
 
31 daniel-mar 85
<h3 id="gen_uuidv6"><font color="green">New:</font> Generate reordered time-based (version 6) UUID</h3>
2 daniel-mar 86
 
31 daniel-mar 87
<p><i>Like UUIDv1, this kind of UUID is made of the MAC address of the generating computer,
88
        the time, and a clock sequence. However, the components in UUIDv6 are reordered (time is at the beginning),
89
        so that UUIDs are monotonically increasing.</i></p>
2 daniel-mar 90
 
31 daniel-mar 91
<?php
92
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
93
        echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs which were created just for you! (Reload the page to get more)</p>';
94
 
95
        echo '<pre>';
96
        for ($i=0; $i<10; $i++) {
97
                $uuid = gen_uuid_v6();
98
                echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>';
99
        }
100
        echo '</pre>';
101
}
102
?>
103
 
2 daniel-mar 104
<form method="GET" action="interprete_uuid.php">
31 daniel-mar 105
    <input type="hidden" name="version" value="6">
106
    <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID">
30 daniel-mar 107
</form>
108
 
31 daniel-mar 109
<h3 id="gen_uuidv4">Generate random (version 4) UUID &#x1F3B2;</h3>
30 daniel-mar 110
 
31 daniel-mar 111
<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 112
 
31 daniel-mar 113
<?php
114
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
115
        echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs which were created just for you! (Reload the page to get more)</p>';
116
 
117
        echo '<pre>';
118
        for ($i=0; $i<10; $i++) {
119
                $uuid = gen_uuid_v4();
120
                echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>';
121
        }
122
        echo '</pre>';
123
}
124
?>
125
 
30 daniel-mar 126
<form method="GET" action="interprete_uuid.php">
31 daniel-mar 127
    <input type="hidden" name="version" value="4">
128
    <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID">
30 daniel-mar 129
</form>
130
 
31 daniel-mar 131
<h3 id="gen_uuidv1">Generate time-based (version 1) UUID</h3>
30 daniel-mar 132
 
31 daniel-mar 133
<p><i>A UUIDv1 is made of the MAC address of the generating computer,
134
the time, and a clock sequence.</i></p>
30 daniel-mar 135
 
31 daniel-mar 136
<?php
137
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
138
    echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs which were created just for you! (Reload the page to get more)</p>';
139
 
140
    echo '<pre>';
141
    for ($i=0; $i<10; $i++) {
142
        $uuid = gen_uuid_v1();
143
        echo '<a href="interprete_uuid.php?uuid='.$uuid.'">'.$uuid.'</a><br>';
144
    }
145
    echo '</pre>';
146
}
147
?>
148
 
30 daniel-mar 149
<form method="GET" action="interprete_uuid.php">
31 daniel-mar 150
    <input type="hidden" name="version" value="1">
151
    <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create and display another UUID">
30 daniel-mar 152
</form>
153
 
31 daniel-mar 154
<h2 id="gen_other_uuid">Generate other UUID types</h2>
30 daniel-mar 155
 
156
<p><i>The following types of UUIDs are less common. Please only use the following
157
generators if you know what you are doing.</i></p>
158
 
31 daniel-mar 159
<h3 id="gen_uuid_nce">NCE (variant 0) UUID</h3>
30 daniel-mar 160
 
161
<p>The NCE UUIDs are a legacy format that cannot be generated anymore, because the
162
amount of available timestamp bits was exhausted on <strong>5 September 2015</strong>.
163
Here is an example of the last possible NCE UUID (all bits of the timestamp are set to 1):
164
<a href="interprete_uuid.php?uuid=ffffffff-ffff-0000-027f-000001000000">ffffffff-ffff-0000-027f-000001000000</a>.</p>
165
 
31 daniel-mar 166
<h3 id="gen_uuidv2">Generate DCE Security (version 2) UUID</h3>
30 daniel-mar 167
 
168
<form method="GET" action="interprete_uuid.php">
2 daniel-mar 169
        <input type="hidden" name="version" value="2">
170
        Domain (8 bits): <select name="domain_choose" id="dce_domain_choice" onchange="javascript:dce_domain_choose();">
171
                <option value="uid">POSIX UID</option>
172
                <option value="gid">POSIX GID</option>
173
                <option value="org">Org</option>
174
                <option value="site">Site-defined</option>
175
        </select> <input type="text" name="dce_domain" value="" id="dce_domain" style="width:50px"> (decimal notation)<br>
30 daniel-mar 176
        Value (32 bits): <input type="text" name="dce_id" value="0" id="dce_id" style="width:200px"> (decimal notation)<br>
177
        <font color="red">Warning</font>: The timestamp has an accuracy of approx. 7 minutes,
178
        therefore the uniqueness of these UUIDs is not guaranteed!<br><br>
2 daniel-mar 179
        <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create UUID">
180
</form>
181
<script>
182
function dce_domain_choose() {
183
        var ns = document.getElementById('dce_domain_choice').value;
184
        if (ns == "uid") {
185
                document.getElementById('dce_domain').value = "0";
186
        }
187
        if (ns == "gid") {
188
                document.getElementById('dce_domain').value = "1";
189
        }
190
        if (ns == "org") {
191
                document.getElementById('dce_domain').value = "2";
192
        }
193
        if (ns == "site") {
194
                document.getElementById('dce_domain').value = "";
195
        }
196
}
197
dce_domain_choose();
198
</script>
199
 
31 daniel-mar 200
<h3 id="gen_uuidv35">Generate name-based (version 3/5) UUID</h3>
2 daniel-mar 201
 
202
<form method="GET" action="interprete_uuid.php">
31 daniel-mar 203
        Hash algorithm: <select name="version">
2 daniel-mar 204
                <option value="3">MD5 (version 3 UUID)</option>
205
                <option value="5">SHA1 (version 5 UUID)</option>
206
        </select><br>
207
        Namespace: <select name="namespace_choose" id="nb_nsc" onchange="javascript:nb_ns_choose();">
208
                <option value="dns">DNS</option>
209
                <option value="url">URL</option>
210
                <option value="oid">OID</option>
211
                <option value="x500">X.500 DN</option>
26 daniel-mar 212
                <option value="oidplus_ns">OIDplus ns only</option>
213
                <option value="oidplus_ns_val">OIDplus ns+val</option>
28 daniel-mar 214
                <!-- <option value="oidplus_pubkey">OIDplus pubkey</option> -->
2 daniel-mar 215
                <option value="other">Other</option>
216
        </select> <input type="text" name="nb_ns" value="" id="nb_ns" style="width:300px"><br>
30 daniel-mar 217
        Value: <input type="text" name="nb_val" value="" id="nb_val" style="width:300px"><br>
218
        <font color="red">Warning</font>: These UUIDs do not contain a timestamp,
219
        therefore the uniqueness of these UUIDs is not guaranteed!<br><br>
2 daniel-mar 220
        <input type="hidden" name="uuid" value="CREATE"> <input type="submit" value="Create UUID">
221
</form>
222
<script>
223
function nb_ns_choose() {
224
        var ns = document.getElementById('nb_nsc').value;
225
        if (ns == "dns") {
226
                document.getElementById('nb_ns').value = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
227
                document.getElementById('nb_val').value = "www.example.org";
228
        }
229
        if (ns == "url") {
230
                document.getElementById('nb_ns').value = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
231
                document.getElementById('nb_val').value = "http://www.example.org/";
232
        }
233
        if (ns == "oid") {
234
                document.getElementById('nb_ns').value = "6ba7b812-9dad-11d1-80b4-00c04fd430c8";
235
                document.getElementById('nb_val').value = "2.999";
236
        }
237
        if (ns == "x500") {
238
                document.getElementById('nb_ns').value = "6ba7b814-9dad-11d1-80b4-00c04fd430c8";
239
                document.getElementById('nb_val').value = "UID=jsmith,DC=example,DC=net";
240
        }
241
        if (ns == "oidplus_ns") {
242
                document.getElementById('nb_ns').value = "0943e3ce-4b79-11e5-b742-78e3b5fc7f22";
243
                document.getElementById('nb_val').value = "ipv4";
244
        }
245
        if (ns == "oidplus_ns_val") {
246
                document.getElementById('nb_ns').value = "ad1654e6-7e15-11e4-9ef6-78e3b5fc7f22";
247
                document.getElementById('nb_val').value = "ipv4:8.8.8.8";
248
        }
28 daniel-mar 249
        /*
250
        if (ns == "oidplus_ns_pubkey") {
251
                document.getElementById('nb_ns').value = "fd16965c-8bab-11ed-8744-3c4a92df8582";
31 daniel-mar 252
                document.getElementById('nb_val').value = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqg/PnsC1WX3C1/mUSLuk0DIaDHtEsxBnG0auYJRJ1hBtbUUvItbK0odlKrX2SFo1MJJpu/SSxTzAgqkKZsZe3cCFkgA1svfuH9i94oGLjJ4n0kRJEGlanCmGndJBfIqGDJaQE2BJ8tLxeBrpkd9l0KvJsjhRmqJAb9KYK3KYFsWvT+wyjD3UJ1eHcgLbF/Qb3cwMU/u7Fs7ZpsNMW4phDPlsYsk9XHFpJ1/UCj6G53mYRfOC/ouDdGShlbVLB15s0V95QpnU/7lL8mJ2lE+sTZekGNBA4XbJv2gs21cR4E8zc/z+NyZS7117DYZoJqrAN8sKz6xGoKgQF6wueCK5qQIDAQAB";
28 daniel-mar 253
        }
254
        */
2 daniel-mar 255
        if (ns == "other") {
256
                document.getElementById('nb_ns').value = "";
257
                document.getElementById('nb_val').value = "";
258
        }
259
}
260
nb_ns_choose();
261
</script>
262
 
31 daniel-mar 263
<h2 id="interpret_uuid">Interpret a UUID</h2>
2 daniel-mar 264
 
30 daniel-mar 265
<p>You can enter a UUID in the following notations:</p>
2 daniel-mar 266
 
267
<ul>
268
        <li>Classic notation (case insensitive, curly braces optional): <code>9e83839a-5967-11e4-8c1c-78e3b5fc7f22</code></li>
269
        <li>As OID: <code>2.25.210700883446948645633376489934419689250</code></li>
270
</ul>
271
 
272
<p>The script will output:</p>
273
 
274
<ul>
275
        <li>Notation as UUID and OID</li>
30 daniel-mar 276
        <li>Version, variant, and additional data (date and time, clock seq, node id, etc.)</li>
2 daniel-mar 277
</ul>
278
 
30 daniel-mar 279
<p>Please enter a UUID or UUID OID:</p>
2 daniel-mar 280
 
281
<form method="GET" action="interprete_uuid.php">
282
        <input type="text" name="uuid" value="" style="width:500px"> <input type="submit" value="Go">
283
</form>
284
 
31 daniel-mar 285
<h2 id="interpret_mac">Interpret a MAC address (<abbr title="Media Access Control">MAC</abbr> /
26 daniel-mar 286
<abbr title="Extended Unique Identifier">EUI</abbr> /
287
<abbr title="Extended Local Identifier">ELI</abbr> /
288
<abbr title="Standard Assigned Identifier">SAI</abbr> /
289
<abbr title="Administratively Assigned Identifier">AAI</abbr>)</h2>
2 daniel-mar 290
 
30 daniel-mar 291
<p>You can enter a UUID in the following notations:</p>
2 daniel-mar 292
 
293
<ul>
294
        <li><code>AA-BB-CC-DD-EE-FF</code></li>
295
        <li><code>AA:BB:CC:DD:EE:FF</code></li>
296
        <li><code>AABBCC.DDEEFF</code> (case insensitive)</li>
16 daniel-mar 297
        <li><code>AA-BB-CC-DD-EE-FF-11-22</code> (EUI-64)</li>
298
        <li><code>AA:BB:CC:DD:EE:FF-11-22</code> (EUI-64)</li>
299
        <li><code>fe80::1322:33ff:fe44:5566</code> (IPv6 Link Local / EUI-64)</li>
2 daniel-mar 300
</ul>
301
 
302
<p>The script will output:</p>
303
 
304
<ul>
305
        <li>Information about the I/G and U/L flags.</li>
306
        <li>Information about the entry in the IEEE registry, if available.</li>
307
        <li>Information about the registrant, if available.</li>
308
</ul>
309
 
29 daniel-mar 310
<p>Please enter a MAC (EUI, ELI, SAI, AAI), or IPv6-Link-Local address:</p>
2 daniel-mar 311
 
312
<form method="GET" action="interprete_mac.php">
30 daniel-mar 313
        <input type="text" name="mac" value="" style="width:250px"> <input type="submit" value="Go">
2 daniel-mar 314
</form>
315
 
22 daniel-mar 316
<br><br><br>
317
 
2 daniel-mar 318
</body>
319
 
320
</html>