Subversion Repositories uuid_mac_utils

Rev

Rev 88 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88 Rev 90
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
* UUID & MAC Utils
4
* UUID & MAC Utils
5
* Copyright 2017 - 2024 Daniel Marschall, ViaThinkSoft
5
* Copyright 2017 - 2024 Daniel Marschall, ViaThinkSoft
6
* Version 2024-04-04
6
* Version 2024-04-16
7
*
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with 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
10
* You may obtain a copy of the License at
11
*
11
*
Line 416... Line 416...
416
</script>
416
</script>
417
 
417
 
418
<h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3>
418
<h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3>
419
 
419
 
420
<p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash.
420
<p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash.
421
The revision of RFC4122 also contains an example for a custom UUIDv8 that
421
RFC 9562 also contains an example for a custom UUIDv8 implementation that
422
uses modern hash algorithms.</i></p>
422
uses modern hash algorithms.</i></p>
423
 
423
 
424
<script>
424
<script>
425
function show_uuidv35_info() {
425
function show_uuidv35_info() {
426
        document.getElementById("uuidv35_info_button").style.display = "none";
426
        document.getElementById("uuidv35_info_button").style.display = "none";
Line 434... Line 434...
434
- 12 bit Hash Mid
434
- 12 bit Hash Mid
435
-  2 bit Variant (fix 0b10)
435
-  2 bit Variant (fix 0b10)
436
- 62 bit Hash Low
436
- 62 bit Hash Low
437
 
437
 
438
 
438
 
439
<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>
439
<u>As shown in <a href="https://www.ietf.org/rfc/rfc9562.txt">RFC 9562</a> Appendix B.2:</u>
440
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> )).
440
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> )).
441
 
441
 
442
</pre></p>
442
</pre></p>
443
 
443
 
444
<style>
444
<style>
Line 452... Line 452...
452
 
452
 
453
<form method="GET" action="interprete_uuid.php">
453
<form method="GET" action="interprete_uuid.php">
454
        <label>Hash algorithm:</label><select name="version" id="nb_version" onchange="javascript:nb_version_choose();">
454
        <label>Hash algorithm:</label><select name="version" id="nb_version" onchange="javascript:nb_version_choose();">
455
                <?php
455
                <?php
456
 
456
 
457
                echo "\t\t<option disabled>--- UUIDv3 (defined in RFC 4122) ---</option>\n";
457
                echo "\t\t<option disabled>--- UUIDv3 (defined in RFC 4122/9562) ---</option>\n";
458
                echo "\t\t<option value=\"3\">MD5</option>\n";
458
                echo "\t\t<option value=\"3\">MD5</option>\n";
459
                echo "\t\t<option disabled>--- UUIDv5 (defined in RFC 4122) ---</option>\n";
459
                echo "\t\t<option disabled>--- UUIDv5 (defined in RFC 4122/9562) ---</option>\n";
460
                echo "\t\t<option value=\"5\" selected>SHA1</option>\n";
460
                echo "\t\t<option value=\"5\" selected>SHA1</option>\n";
461
                echo "\t\t<option disabled>--- UUIDv8 (shown in Internet Draft 12, Appendix C.2) ---</option>\n";
461
                echo "\t\t<option disabled>--- UUIDv8 (shown in RFC 9562, Appendix B.2) ---</option>\n";
462
                $tmp = [];
462
                $tmp = [];
463
                $algos = hash_algos();
463
                $algos = hash_algos();
464
                $algos[] = 'shake128';
464
                $algos[] = 'shake128';
465
                $algos[] = 'shake256';
465
                $algos[] = 'shake256';
466
                foreach ($algos as $algo) {
466
                foreach ($algos as $algo) {