Subversion Repositories uuid_mac_utils

Rev

Rev 71 | Rev 74 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 71 Rev 72
Line 18... Line 18...
18
* limitations under the License.
18
* limitations under the License.
19
*/
19
*/
20
 
20
 
21
include_once __DIR__.'/includes/uuid_utils.inc.php';
21
include_once __DIR__.'/includes/uuid_utils.inc.php';
22
 
22
 
23
const AUTO_NEW_UUIDS = 10;
23
const AUTO_NEW_UUIDS = 15;
24
 
24
 
25
?><!DOCTYPE html>
25
?><!DOCTYPE html>
26
<html lang="en">
26
<html lang="en">
27
 
27
 
28
<head>
28
<head>
Line 61... Line 61...
61
 
61
 
62
<h2 id="gen_uuid">Generate random and/or time-based UUIDs</h2>
62
<h2 id="gen_uuid">Generate random and/or time-based UUIDs</h2>
63
 
63
 
64
<h3 id="gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch Time (version 7) UUID &#11088;</h3>
64
<h3 id="gen_uuidv7"><font color="green">New:</font> Generate Unix Epoch Time (version 7) UUID &#11088;</h3>
65
 
65
 
66
<p><i>A UUIDv7 is made of time and 74 random&nbsp;bits.
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.
67
        Since the time is at the beginning, the UUIDs are monotonically increasing.
69
The timestamp is at the front of the UUID, therefore the UUIDs are monotonically increasing,
68
        Due to the missing MAC address, this UUID version is recommended due to
70
which is good for ordering them and using them for database indexes.
-
 
71
Since this UUID version does not contain a MAC address, it is
69
        improved privacy.</i></p>
72
recommended due to the improved privacy.</i></p>
70
 
73
 
71
<script>
74
<script>
72
function show_uuidv7_info() {
75
function show_uuidv7_info() {
73
        document.getElementById("uuidv7_info_button").style.display = "none";
76
        document.getElementById("uuidv7_info_button").style.display = "none";
74
        document.getElementById("uuidv7_info").style.display = "block";
77
        document.getElementById("uuidv7_info").style.display = "block";
Line 95... Line 98...
95
        else if ($resolution_ns >= 1000) $resolution_ns_hf = ($resolution_ns/1000)." &micro;s";
98
        else if ($resolution_ns >= 1000) $resolution_ns_hf = ($resolution_ns/1000)." &micro;s";
96
        else $resolution_ns_hf = "$resolution_ns ns";
99
        else $resolution_ns_hf = "$resolution_ns ns";
97
        echo "$num_ms_frac_bits bits fraction = $resolution_ns_hf\n";
100
        echo "$num_ms_frac_bits bits fraction = $resolution_ns_hf\n";
98
}
101
}
99
?>
102
?>
-
 
103
 
-
 
104
This implementation outputs:
-
 
105
- 12 bits sub-millisecond timestamp (~245ns resolution)
-
 
106
- no counter
-
 
107
- 62 bits random data
100
</pre></p>
108
</pre></p>
101
 
109
 
102
<?php
110
<?php
103
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
111
if (AUTO_NEW_UUIDS > 0) { /** @phpstan-ignore-line */
104
        echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>';
112
        echo '<p>Here are '.AUTO_NEW_UUIDS.' UUIDs that were created just for you! (Reload the page to get more)</p>';
Line 119... Line 127...
119
 
127
 
120
<h3 id="gen_uuidv6"><font color="green">New:</font> Generate reordered time-based (version 6) UUID &#9200;</h3>
128
<h3 id="gen_uuidv6"><font color="green">New:</font> Generate reordered time-based (version 6) UUID &#9200;</h3>
121
 
129
 
122
<p><i>Like UUIDv1, this kind of UUID is made of the MAC address of the generating computer,
130
<p><i>Like UUIDv1, this kind of UUID is made of the MAC address of the generating computer,
123
        the time, and a clock sequence. However, the components in UUIDv6 are reordered (time is at the beginning),
131
        the time, and a clock sequence. However, the components in UUIDv6 are reordered (time is at the beginning),
124
        so that UUIDs are monotonically increasing.</i></p>
132
        so that UUIDs are monotonically increasing,
-
 
133
        which is good for ordering them and using them for database indexes..</i></p>
125
 
134
 
126
<script>
135
<script>
127
function show_uuidv6_info() {
136
function show_uuidv6_info() {
128
        document.getElementById("uuidv6_info_button").style.display = "none";
137
        document.getElementById("uuidv6_info_button").style.display = "none";
129
        document.getElementById("uuidv6_info").style.display = "block";
138
        document.getElementById("uuidv6_info").style.display = "block";
Line 333... Line 342...
333
 
342
 
334
<h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3>
343
<h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3>
335
 
344
 
336
<p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash.
345
<p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash.
337
The revision of RFC4122 also contains an example for a custom UUIDv8 that
346
The revision of RFC4122 also contains an example for a custom UUIDv8 that
338
allows SHA2, SHA3 and SHAKE hash algorithms.</i></p>
347
uses modern hash algorithms.</i></p>
339
 
348
 
340
<script>
349
<script>
341
function show_uuidv35_info() {
350
function show_uuidv35_info() {
342
        document.getElementById("uuidv35_info_button").style.display = "none";
351
        document.getElementById("uuidv35_info_button").style.display = "none";
343
        document.getElementById("uuidv35_info").style.display = "block";
352
        document.getElementById("uuidv35_info").style.display = "block";