Subversion Repositories uuid_mac_utils

Compare Revisions

Regard whitespace Rev 89 → Rev 90

/trunk/includes/uuid_utils.inc.php
3,7 → 3,7
/*
* UUID utils for PHP
* Copyright 2011 - 2024 Daniel Marschall, ViaThinkSoft
* Version 2024-04-05
* Version 2024-04-16
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
333,7 → 333,7
} else if (($version >= 3) && ($version <= 5)) {
echo sprintf("%-32s %s\n", "Variant:", "[0b10_] RFC 4122 (Leach-Mealling-Salz)");
} else if (($version >= 6) && ($version <= 8)) {
echo sprintf("%-32s %s\n", "Variant:", "[0b10_] RFC draft-ietf-uuidrev-rfc4122bis (Davis-Peabody-Leach)"); // TODO: When new RFC is published, replace the RFC number
echo sprintf("%-32s %s\n", "Variant:", "[0b10_] RFC 9562 (Davis-Peabody-Leach)");
} else {
echo sprintf("%-32s %s\n", "Variant:", "[0b10_] Unknown RFC");
}
922,7 → 922,7
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'.
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'".
str_pad("$milliseconds",3/*ms*/,'0',STR_PAD_LEFT);
if (checkdate($month, $day, $year) && (strpos($utc_time,'X') === false)) {
if ((strpos($utc_time,'X') === false) && checkdate($month, $day, $year)) {
$deviation = "(deviation -2ms..2ms)";
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 2</a></u>\n\n";
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad("".base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT));
967,7 → 967,7
str_pad("$minutes",2,'0',STR_PAD_LEFT).':'.
str_pad("$seconds",2,'0',STR_PAD_LEFT)."'".
str_pad("$milliseconds",3/*ms*/,'0',STR_PAD_LEFT);
if (checkdate($month, $day, $year) && (strpos($local_time,'X') === false)) {
if ((strpos($local_time,'X') === false) && checkdate($month, $day, $year)) {
$deviation = "(deviation -4ms..0ms)";
echo "\n<u>Interpretation of <a href=\"https://gist.github.com/danielmarschall/7fafd270a3bc107d38e8449ce7420c25\">HickelSOFT \"SQL Server Sortable Custom UUID\", Version 1</a></u>\n\n";
echo sprintf("%-32s %s\n", "Random 16 bits:", "[0x$rnd16bits] 0b".str_pad(base_convert($rnd16bits, 16, 2), 16, '0', STR_PAD_LEFT));
1638,7 → 1638,7
$year = $dt->format('Y');
$block4 = substr($year, 2, 2).substr($year, 0, 2); // Example: 0x2420 = 2024
} else {
$variant = 0x8; // First nibble needs to be 0b10_ (0x8-0xB) for "RFC 4122bis". We use it to store 2 more random bits.
$variant = 0x8; // First nibble needs to be 0b10_ (0x8-0xB) for RFC 9562. We use it to store 2 more random bits.
$unused2bits = 0; // Cannot be used for random, because it would affect the sorting
$year = $dt->format('Y');
$block4 = sprintf('%01x%03x', $variant + ($unused2bits & 0x3), $year);
/trunk/index.php
3,7 → 3,7
/*
* UUID & MAC Utils
* Copyright 2017 - 2024 Daniel Marschall, ViaThinkSoft
* Version 2024-04-04
* Version 2024-04-16
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
418,7 → 418,7
<h3 id="gen_uuidv35">Generate name-based (version 3 / 5 / <font color="green">New: 8</font>) UUID</h3>
 
<p><i>An UUIDv3 is made out of a MD5 hash and an UUIDv5 is made out of a SHA1 hash.
The revision of RFC4122 also contains an example for a custom UUIDv8 that
RFC 9562 also contains an example for a custom UUIDv8 implementation that
uses modern hash algorithms.</i></p>
 
<script>
436,7 → 436,7
- 62 bit Hash Low
 
 
<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>
<u>As shown in <a href="https://www.ietf.org/rfc/rfc9562.txt">RFC 9562</a> Appendix B.2:</u>
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> )).
 
</pre></p>
454,11 → 454,11
<label>Hash algorithm:</label><select name="version" id="nb_version" onchange="javascript:nb_version_choose();">
<?php
 
echo "\t\t<option disabled>--- UUIDv3 (defined in RFC 4122) ---</option>\n";
echo "\t\t<option disabled>--- UUIDv3 (defined in RFC 4122/9562) ---</option>\n";
echo "\t\t<option value=\"3\">MD5</option>\n";
echo "\t\t<option disabled>--- UUIDv5 (defined in RFC 4122) ---</option>\n";
echo "\t\t<option disabled>--- UUIDv5 (defined in RFC 4122/9562) ---</option>\n";
echo "\t\t<option value=\"5\" selected>SHA1</option>\n";
echo "\t\t<option disabled>--- UUIDv8 (shown in Internet Draft 12, Appendix C.2) ---</option>\n";
echo "\t\t<option disabled>--- UUIDv8 (shown in RFC 9562, Appendix B.2) ---</option>\n";
$tmp = [];
$algos = hash_algos();
$algos[] = 'shake128';