Subversion Repositories uuid_mac_utils

Compare Revisions

Regard whitespace Rev 68 → Rev 69

/trunk/includes/uuid_utils.inc.php
3,7 → 3,7
/*
* UUID utils for PHP
* Copyright 2011 - 2023 Daniel Marschall, ViaThinkSoft
* Version 2023-09-07
* Version 2023-09-23
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
972,7 → 972,7
$uuid['time_low'] = gmp_and($time, gmp_init('ffffffff',16));
$high = gmp_shiftr($time,32);
$uuid['time_mid'] = gmp_and($high, gmp_init('ffff',16));
$uuid['time_hi'] = intval(gmp_and(gmp_shiftr($high,16),gmp_init('fff',16)),10) | (1/*TimeBased*/ << 12);
$uuid['time_hi'] = gmp_intval(gmp_and(gmp_shiftr($high,16),gmp_init('fff',16))) | (1/*TimeBased*/ << 12);
} else {
$time = ($tp['sec'] * 10000000) + ($tp['usec'] * 10) + 0x01B21DD213814000;
$uuid['time_low'] = $time & 0xffffffff;
1274,33 → 1274,36
return strtolower($block1.'-'.$block2.'-'.$block3.'-'.$block4.'-'.$block5);
}
 
function gen_uuid_v8_namebased($hash_uuid, $namespace_uuid, $name) {
if (($hash_uuid ?? '') === '') throw new Exception("Hash space UUID missing");
if (!uuid_valid($hash_uuid)) throw new Exception("Invalid hash space ID '$hash_uuid'");
function gen_uuid_v8_namebased($hash_algo, $namespace_uuid, $name) {
if (($hash_algo ?? '') === '') throw new Exception("Hash algorithm argument missing");
 
if (($namespace_uuid ?? '') === '') throw new Exception("Namespace UUID missing");
if (!uuid_valid($namespace_uuid)) throw new Exception("Invalid namespace UUID '$namespace_uuid'");
 
$uuid1 = hex2bin(str_replace('-','',uuid_canonize($hash_uuid)));
$uuid1 = uuid_valid($hash_algo) ? hex2bin(str_replace('-','',uuid_canonize($hash_algo))) : '';
$uuid2 = hex2bin(str_replace('-','',uuid_canonize($namespace_uuid)));
$payload = $uuid1 . $uuid2 . $name;
 
$hash = null;
if (uuid_valid($hash_algo)) {
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) {
if (uuid_equal($hash_uuid,$space)) {
if (uuid_equal($hash_algo,$space)) {
if (!$available) {
throw new Exception("Algorithm $algo is not available on this system (PHP version too old)");
}
 
if ($algo == 'shake128') $hash = shake128($payload, 16/*min. required bytes*/, false);
else if ($algo == 'shake256') $hash = shake256($payload, 16/*min. required bytes*/, false);
else $hash = hash($algo, $payload, false);
$hash_algo = $algo;
break;
}
}
}
 
if ($hash_algo == 'shake128') $hash = shake128($payload, 16/*min. required bytes*/, false);
else if ($hash_algo == 'shake256') $hash = shake256($payload, 16/*min. required bytes*/, false);
else $hash = hash($hash_algo, $payload, false);
 
$hash = str_pad($hash, 32, '0', STR_PAD_RIGHT); // fill short hashes with zeros to the right
 
if ($hash == null) {
throw new Exception("Unknown Hash Space UUID $hash_uuid");
throw new Exception("Unknown Hash Algorithm $hash_algo");
}
 
$hash[12] = '8'; // Set version: 8 = Custom
1315,7 → 1318,7
 
/**
* Collection of Namebased UUIDv8 Hash Space IDs
* @return array An array containing tuples of [PHP Algo Name, Hash Space UUID, Human friendly name, Hash Space Author, Available, AlgorithmOID]
* @return array An array containing tuples of [PHP Algo Name, Hash Space UUID, Human friendly name, Hash Space Author, Available]
*/
function get_uuidv8_hash_space_ids(): array {
$out = array();
1322,106 → 1325,19
 
// The following Hash Space UUIDs are defined in draft-ietf-uuidrev-rfc4122bis-11 as Example for Namebased UUIDv8
$category = 'Internet Draft 11, Appendix B';
$out[] = ['sha224', '59031ca3-fbdb-47fb-9f6c-0f30e2e83145', 'SHA-224', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha256', '3fb32780-953c-4464-9cfd-e85dbbe9843d', 'SHA-256', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha384', 'e6800581-f333-484b-8778-601ff2b58da8', 'SHA-384', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha512', '0fde22f2-e7ba-4fd1-9753-9c2ea88fa3f9', 'SHA-512', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha512/224', '003c2038-c4fe-4b95-a672-0c26c1b79542', 'SHA-512/224', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha512/256', '9475ad00-3769-4c07-9642-5e7383732306', 'SHA-512/256', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha3-224', '9768761f-ac5a-419e-a180-7ca239e8025a', 'SHA3-224', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha3-256', '2034d66b-4047-4553-8f80-70e593176877', 'SHA3-256', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha3-384', '872fb339-2636-4bdd-bda6-b6dc2a82b1b3', 'SHA3-384', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['sha3-512', 'a4920a5d-a8a6-426c-8d14-a6cafbe64c7b', 'SHA3-512', $category, PHP_VERSION_ID >= 70100, null];
$out[] = ['shake128'/*Currently no PHP core algorithm!*/, '7ea218f6-629a-425f-9f88-7439d63296bb', 'SHAKE128', $category, file_exists(__DIR__.'/SHA3.php'), null];
$out[] = ['shake256'/*Currently no PHP core algorithm!*/, '2e7fc6a4-2919-4edc-b0ba-7d7062ce4f0a', 'SHAKE256', $category, file_exists(__DIR__.'/SHA3.php'), null];
$out[] = ['sha224', '59031ca3-fbdb-47fb-9f6c-0f30e2e83145', 'SHA-224', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha256', '3fb32780-953c-4464-9cfd-e85dbbe9843d', 'SHA-256', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha384', 'e6800581-f333-484b-8778-601ff2b58da8', 'SHA-384', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha512', '0fde22f2-e7ba-4fd1-9753-9c2ea88fa3f9', 'SHA-512', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha512/224', '003c2038-c4fe-4b95-a672-0c26c1b79542', 'SHA-512/224', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha512/256', '9475ad00-3769-4c07-9642-5e7383732306', 'SHA-512/256', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha3-224', '9768761f-ac5a-419e-a180-7ca239e8025a', 'SHA3-224', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha3-256', '2034d66b-4047-4553-8f80-70e593176877', 'SHA3-256', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha3-384', '872fb339-2636-4bdd-bda6-b6dc2a82b1b3', 'SHA3-384', $category, PHP_VERSION_ID >= 70100];
$out[] = ['sha3-512', 'a4920a5d-a8a6-426c-8d14-a6cafbe64c7b', 'SHA3-512', $category, PHP_VERSION_ID >= 70100];
$out[] = ['shake128'/*Currently no PHP core algorithm!*/, '7ea218f6-629a-425f-9f88-7439d63296bb', 'SHAKE128', $category, file_exists(__DIR__.'/SHA3.php')];
$out[] = ['shake256'/*Currently no PHP core algorithm!*/, '2e7fc6a4-2919-4edc-b0ba-7d7062ce4f0a', 'SHAKE256', $category, file_exists(__DIR__.'/SHA3.php')];
 
// ---
 
// Proposal https://github.com/ietf-wg-uuidrev/rfc4122bis/issues/143#issuecomment-1709117798 , probably to be put into Draft 12
$category = 'Internet Draft 12 Proposal';
$out[] = ['sha224', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.4'), 'SHA-224', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha256', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.1'), 'SHA-256', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha384', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.2'), 'SHA-384', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha512', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.3'), 'SHA-512', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha512/224', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.5'), 'SHA-512/224', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha512/256', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.6'), 'SHA-512/256', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha3-224', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.7'), 'SHA3-224', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha3-256', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.8'), 'SHA3-256', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha3-384', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.9'), 'SHA3-384', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['sha3-512', gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.10'), 'SHA3-512', $category, PHP_VERSION_ID >= 70100, $oid];
$out[] = ['shake128'/*Currently no PHP core algorithm!*/, gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.11'), 'SHAKE128', $category, file_exists(__DIR__.'/SHA3.php'), $oid];
$out[] = ['shake256'/*Currently no PHP core algorithm!*/, gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid='2.16.840.1.101.3.4.2.12'), 'SHAKE256', $category, file_exists(__DIR__.'/SHA3.php'), $oid];
 
// ---
 
// The following Hash Space UUIDs are defined by ViaThinkSoft
// UUIDv8_NamebasedViaThinkSoft := <HashAlgo>_AsUUIDv8( BinaryHashSpaceUUID + BinaryNamespaceUUID + Data )
// Algorithms which have an OID get defined as follows:
// BinaryHashSpaceUUID := SHA1_AsUUIDv5( hex2bin(NS_OID) + AlgorithmOID )
// If no OID can be found, the hash space is constructed using a custom namespace and the PHP name as payload:
// BinaryHashSpaceUUID := SHA1_AsUUIDv5( hex2bin('1ee317e2-1853-64b2-8fe9-3c4a92df8582') + PhpHashAlgoName )
$available_algos = hash_algos();
$unavailable_algos = [];
if (PHP_VERSION_ID < 80100/*8.1.0*/) {
$unavailable_algos[] = 'murmur3c'; // length: 16 bytes
$unavailable_algos[] = 'murmur3f'; // length: 16 bytes
$unavailable_algos[] = 'xxh128'; // length: 16 bytes
}
if (PHP_VERSION_ID < 99999) {
// How to update this list $unavailable_algos:
// 1. Look if new hashes are listed in the PHP documentation: https://www.php.net/manual/de/function.hash-algos.php
// 2. If the required version is lower than our server version, then you don't need to do anything
// 3. Otherwise, run this command on a different machine (where the algorithms are implemented) to check if the hashes have the correct length
// foreach (hash_algos() as $algo) {
// $len = strlen(hash($algo, '', false));
// if ($len >= 32) echo "$algo, length $len\n";
// }
// 4. Then, include all fitting hashes here
// 5. Please publish the new hash space IDs here: https://oidplus.viathinksoft.com/oidplus/?goto=guid%3Auuid_mac_utils%2Fuuidv8_hash_space_vts
}
$all_algos = array_merge($available_algos, $unavailable_algos);
 
foreach ($all_algos as $algo) {
if ($algo == 'md5') continue; // MD5 is already used in UUIDv3
if ($algo == 'sha1') continue; // SHA1 is already used in UUIDv5
foreach ($out as list($algo2,$space,$friendlyName,$author)) {
if ($algo == $algo2) continue 2; // UUID is already defined by RFC, don't need a VTS Hash Space UUID
}
if (in_array($algo,$available_algos) && (strlen(hash($algo,'',false)) < 32)) continue; // Hash too short (needs at least 16 bytes)
 
// List of OIDs here: https://github.com/ietf-wg-uuidrev/rfc4122bis/issues/143#issuecomment-1709117798
$oid = null;
if ($algo == 'gost') $oid = '1.2.643.2.2.30.0';
if ($algo == 'gost-crypto') $oid = '1.2.643.2.2.30.1';
if ($algo == 'haval128,3') $oid = '1.3.6.1.4.1.18105.2.1.1.1';
if ($algo == 'haval160,3') $oid = '1.3.6.1.4.1.18105.2.1.1.2';
if ($algo == 'haval192,3') $oid = '1.3.6.1.4.1.18105.2.1.1.3';
if ($algo == 'haval224,3') $oid = '1.3.6.1.4.1.18105.2.1.1.4';
if ($algo == 'haval256,3') $oid = '1.3.6.1.4.1.18105.2.1.1.5';
if ($algo == 'haval128,4') $oid = '1.3.6.1.4.1.18105.2.1.1.6';
if ($algo == 'haval160,4') $oid = '1.3.6.1.4.1.18105.2.1.1.7';
if ($algo == 'haval192,4') $oid = '1.3.6.1.4.1.18105.2.1.1.8';
if ($algo == 'haval224,4') $oid = '1.3.6.1.4.1.18105.2.1.1.9';
if ($algo == 'haval256,4') $oid = '1.3.6.1.4.1.18105.2.1.1.10';
if ($algo == 'haval128,5') $oid = '1.3.6.1.4.1.18105.2.1.1.11';
if ($algo == 'haval160,5') $oid = '1.3.6.1.4.1.18105.2.1.1.12';
if ($algo == 'haval192,5') $oid = '1.3.6.1.4.1.18105.2.1.1.13';
if ($algo == 'haval224,5') $oid = '1.3.6.1.4.1.18105.2.1.1.14';
if ($algo == 'haval256,5') $oid = '1.3.6.1.4.1.18105.2.1.1.15';
if ($algo == 'md2') $oid = '1.2.840.113549.2.2';
if ($algo == 'md4') $oid = '1.2.840.113549.2.4';
if ($algo == 'ripemd128') $oid = '1.3.36.3.2.2'; // or 1.0.10118.3.0.50
if ($algo == 'ripemd160') $oid = '1.3.36.3.2.1'; // or 1.0.10118.3.0.49
if ($algo == 'ripemd256') $oid = '1.3.36.3.2.3';
if ($algo == 'whirlpool') $oid = '1.0.10118.3.0.55';
 
if ($oid == null) {
$out[] = [$algo, gen_uuid_v5('1ee317e2-1853-64b2-8fe9-3c4a92df8582', $algo), strtoupper($algo), 'ViaThinkSoft by PHP name', in_array($algo,$available_algos), $oid];
} else {
$out[] = [$algo, gen_uuid_v5(UUID_NAMEBASED_NS_OID, $oid), strtoupper($algo), 'ViaThinkSoft by OID', in_array($algo,$available_algos), $oid];
}
}
 
return $out;
}
 
/trunk/index.php
3,7 → 3,7
/*
* UUID & MAC Utils
* Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft
* Version 2023-09-07
* Version 2023-09-23
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
318,8 → 318,7
 
<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
allows SHA2, SHA3 and SHAKE hash algorithms. ViaThinkSoft added more hash
algorithms and assigned Hash Space IDs to them.</i></p>
allows SHA2, SHA3 and SHAKE hash algorithms.</i></p>
 
<script>
function show_uuidv35_info() {
336,32 → 335,26
- 62 bit Hash Low
 
 
 
<u>Overview of namebased UUIDs:</u>
<u>As defined by <a href="https://datatracker.ietf.org/doc/rfc4122/">RFC4122</a>:</u>
UUIDv3(<i>NamespaceUuid</i>, <i>Data</i>) := <abbr title="Adds UUID variant 0b10 and version 3">ConvertRawBytesToUuid_v3</abbr>(MD5( Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )).
UUIDv5(<i>NamespaceUuid</i>, <i>Data</i>) := <abbr title="Adds UUID variant 0b10 and version 5">ConvertRawBytesToUuid_v5</abbr>(SHA1( Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )).
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[HashSpaceUuid&lt;<i>HashAlgo</i>&gt;] || Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )).
 
<u>As defined by <a href="https://datatracker.ietf.org/doc/rfc4122/">RFC4122</a> Appendix C / <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">draft-ietf-uuidrev-rfc4122bis-11</a> Appendix A:</u><!-- TODO: When new RFC is published, replace the RFC number -->
NameSpaceUuid&lt;DNS&gt; := "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
NameSpaceUuid&lt;URL&gt; := "6ba7b811-9dad-11d1-80b4-00c04fd430c8".
NameSpaceUuid&lt;OID&gt; := "6ba7b812-9dad-11d1-80b4-00c04fd430c8".
NameSpaceUuid&lt;X500&gt; := "6ba7b814-9dad-11d1-80b4-00c04fd430c8".
 
<u>As defined by <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">draft-ietf-uuidrev-rfc4122bis-11</a> Appendix B:</u>
<u>As defined by <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">draft-ietf-uuidrev-rfc4122bis-11</a>:</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[HashSpaceUuid&lt;<i>HashAlgo</i>&gt;] || Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )).
<?php
 
$tmp = [];
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available,$oid)) {
if (strpos($author,'ViaThinkSoft') === false) {
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) {
$line = str_pad('HashSpaceUuid&lt;'.htmlentities($friendlyName).'&gt;', 34, ' ', STR_PAD_RIGHT);
$line .= ':= "'.$space.'".';
if (!$available) $line .= " (Currently not available on this system)";
$line .= "\n";
if (isset($tmp[$friendlyName])) continue; // Ignore "Internet Draft 12 Proposal"
$tmp[$friendlyName] = $line;
}
}
ksort($tmp);
foreach ($tmp as $line) {
echo $line;
369,57 → 362,9
 
?>
 
<u>As defined in <a href="https://github.com/ietf-wg-uuidrev/rfc4122bis/issues/143#issuecomment-1709117798">Internet Draft 12 Proposal</a>:</u>
HashSpaceUuid&lt;<i>HashAlgo</i>&gt; := UUIDv5(NS_OID, OID[<i>HashAlgo</i>]).
which results in the following UUIDs:
<?php
<u>Custom implementation ("Raw Hash"):</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> )).
 
$tmp = [];
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available,$oid)) {
if (strpos($author,'ViaThinkSoft') === false) {
$line = str_pad('HashSpaceUuid&lt;'.htmlentities($friendlyName).'&gt;', 34, ' ', STR_PAD_RIGHT);
if ($oid != null) $line .= str_pad(':= UUIDv5(NS_OID, "'.$oid.'")', 46, ' ', STR_PAD_RIGHT);
if ($oid == null) $line .= str_pad(':= UUIDv5(NS_PHPNAME, "'.$algo.'")', 46, ' ', STR_PAD_RIGHT);
$line .= '= "'.$space.'".';
if (!$available) $line .= " (Currently not available on this system)";
$line .= "\n";
$tmp[$friendlyName] = $line;
}
}
ksort($tmp);
foreach ($tmp as $line) {
echo $line;
}
 
?>
 
<u>As defined by ViaThinkSoft for all other algorithms:</u>
HashSpaceUuid&lt;<i>HashAlgo</i>&gt; := UUIDv5(NS_OID, OID[<i>HashAlgo</i>]).
or in case no OID can be found:
HashSpaceUuid&lt;<i>HashAlgo</i>&gt; := UUIDv5(NS_PHPNAME="1ee317e2-1853-64b2-8fe9-3c4a92df8582", <a href="https://www.php.net/manual/de/function.hash-algos.php">PhpName</a>[<i>HashAlgo</i>]).
which results in the following UUIDs:
<?php
 
$tmp = [];
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available,$oid)) {
if (strpos($author,'ViaThinkSoft') !== false) {
$line = str_pad('HashSpaceUuid&lt;'.htmlentities($friendlyName).'&gt;', 34, ' ', STR_PAD_RIGHT);
if ($oid != null) $line .= str_pad(':= UUIDv5(NS_OID, "'.$oid.'")', 53, ' ', STR_PAD_RIGHT);
if ($oid == null) $line .= str_pad(':= UUIDv5(NS_PHPNAME, "'.$algo.'")', 53, ' ', STR_PAD_RIGHT);
$line .= '= "'.$space.'".';
if (!$available) $line .= " (Currently not available on this system)";
$line .= "\n";
$tmp[$friendlyName] = $line;
}
}
ksort($tmp);
foreach ($tmp as $line) {
echo $line;
}
 
?>
 
 
</pre></p>
 
<style>
460,6 → 405,30
echo "\t\t$html\n";
}
}
 
echo "\t\t<option disabled>--- UUIDv8 (Raw Hash) ---</option>\n";
$tmp = [];
$algos = hash_algos();
$algos[] = 'shake128';
$algos[] = 'shake256';
foreach ($algos as $algo) {
if ($algo == 'md5') continue; // use UUIDv3 instead
if ($algo == 'sha1') continue; // use UUIDv5 instead
$friendlyName = strtoupper($algo);
 
if ($algo == 'shake128') $bits = 999;
else if ($algo == 'shake256') $bits = 999;
else $bits = strlen(hash($algo, '', true)) * 8;
if ($bits < 128) $friendlyName .= " (Small hash size! $bits bits)";
 
$space = $algo;
$tmp[$friendlyName] = '<option value="8_namebased_'.$space.'">'.htmlentities($friendlyName).'</option>';
}
natsort($tmp);
foreach ($tmp as $html) {
echo "\t\t$html\n";
}
 
?>
</select><font size="-1"><span id="nb_hash_info"></span></font><br>
<label>Namespace:</label><select name="namespace_choose" id="nb_nsc" onchange="javascript:nb_ns_choose();">
482,7 → 451,7
var ver = document.getElementById('nb_version').value;
document.getElementById('nb_create_btn').value = 'Create UUIDv' + ver.substr(0,1);
var x = ver.split('_namebased_');
if (x.length == 2) {
if ((x.length == 2) && (x[1].length == 36)) {
document.getElementById('nb_hash_info').innerHTML = ' (UUIDv8 Hash Space ID: ' + x[1] + ')';
} else {
document.getElementById('nb_hash_info').innerHTML = '';