Rev 65 | Rev 67 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 65 | Rev 66 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * UUID & MAC Utils |
4 | * UUID & MAC Utils |
5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
6 | * Version 2023-08-16 |
6 | * Version 2023-09-06 |
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 340... | Line 340... | ||
340 | <u>Overview of namebased UUIDs:</u> |
340 | <u>Overview of namebased UUIDs:</u> |
341 | 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> )). |
341 | 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> )). |
342 | 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> )). |
342 | 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> )). |
343 | 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<<i>HashAlgo</i>>] || Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )). |
343 | 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<<i>HashAlgo</i>>] || Binary[<i>NameSpaceUuid</i>] || <i>Data</i> )). |
344 | 344 | ||
345 | <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/">RFC4122bis</a> Appendix A:</u><!-- TODO: When new RFC is published, replace the RFC number --> |
345 | <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 --> |
346 | NameSpaceUuid<DNS> := "6ba7b810-9dad-11d1-80b4-00c04fd430c8". |
346 | NameSpaceUuid<DNS> := "6ba7b810-9dad-11d1-80b4-00c04fd430c8". |
347 | NameSpaceUuid<URL> := "6ba7b811-9dad-11d1-80b4-00c04fd430c8". |
347 | NameSpaceUuid<URL> := "6ba7b811-9dad-11d1-80b4-00c04fd430c8". |
348 | NameSpaceUuid<OID> := "6ba7b812-9dad-11d1-80b4-00c04fd430c8". |
348 | NameSpaceUuid<OID> := "6ba7b812-9dad-11d1-80b4-00c04fd430c8". |
349 | NameSpaceUuid<X500> := "6ba7b814-9dad-11d1-80b4-00c04fd430c8". |
349 | NameSpaceUuid<X500> := "6ba7b814-9dad-11d1-80b4-00c04fd430c8". |
350 | 350 | ||
351 | <u>As defined by <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">RFC4122bis</a> Appendix B:</u><!-- TODO: When new RFC is published, replace the RFC number --> |
351 | <u>As defined by <a href="https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/">draft-ietf-uuidrev-rfc4122bis-11</a> Appendix B:</u><!-- TODO: When new RFC is published, replace the RFC number --> |
- | 352 | <?php |
|
- | 353 | ||
- | 354 | $tmp = []; |
|
352 | HashSpaceUuid<SHA2_224> := "59031ca3-fbdb-47fb-9f6c-0f30e2e83145". |
355 | foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) { |
353 | HashSpaceUuid<SHA2_256> := "3fb32780-953c-4464-9cfd-e85dbbe9843d". |
356 | if (strpos($author,'ViaThinkSoft') === false) { |
354 | HashSpaceUuid<SHA2_384> := "e6800581-f333-484b-8778-601ff2b58da8". |
357 | $line = str_pad('HashSpaceUuid<'.htmlentities($friendlyName).'>', 34, ' ', STR_PAD_RIGHT); |
355 | HashSpaceUuid<SHA2_512> := "0fde22f2-e7ba-4fd1-9753-9c2ea88fa3f9". |
358 | $line .= ':= "'.$space.'".'; |
356 | HashSpaceUuid<SHA2_512_224> := "003c2038-c4fe-4b95-a672-0c26c1b79542". |
- | |
357 | HashSpaceUuid<SHA2_512_256> := "9475ad00-3769-4c07-9642-5e7383732306". |
- | |
358 | HashSpaceUuid<SHA3_224> := "9768761f-ac5a-419e-a180-7ca239e8025a". |
359 | if (!$available) $line .= " (Currently not available on this system)"; |
359 | HashSpaceUuid<SHA3_256> := "2034d66b-4047-4553-8f80-70e593176877". |
- | |
360 | HashSpaceUuid<SHA3_384> := "872fb339-2636-4bdd-bda6-b6dc2a82b1b3". |
360 | $line .= "\n"; |
361 | HashSpaceUuid<SHA3_512> := "a4920a5d-a8a6-426c-8d14-a6cafbe64c7b". |
361 | $tmp[$friendlyName] = $line; |
- | 362 | } |
|
- | 363 | } |
|
- | 364 | ksort($tmp); |
|
362 | HashSpaceUuid<SHAKE_128> := "7ea218f6-629a-425f-9f88-7439d63296bb". |
365 | foreach ($tmp as $line) { |
363 | HashSpaceUuid<SHAKE_256> := "2e7fc6a4-2919-4edc-b0ba-7d7062ce4f0a". |
366 | echo $line; |
- | 367 | } |
|
- | 368 | ||
- | 369 | ?> |
|
364 | 370 | ||
365 | <u>As defined by ViaThinkSoft for all other algorithms:</u> |
371 | <u>As defined by ViaThinkSoft for all other algorithms:</u> |
366 | HashSpaceUuid<<i>HashAlgo</i>> := UUIDv5("1ee317e2-1853-64b2-8fe9-3c4a92df8582", <a href="https://www.php.net/manual/de/function.hash-algos.php">PhpName</a>[<i>HashAlgo</i>]). |
372 | HashSpaceUuid<<i>HashAlgo</i>> := UUIDv5("1ee317e2-1853-64b2-8fe9-3c4a92df8582", <a href="https://www.php.net/manual/de/function.hash-algos.php">PhpName</a>[<i>HashAlgo</i>]). |
367 | which results in the following UUIDs: |
373 | which results in the following UUIDs: |
368 | <?php |
374 | <?php |
369 | 375 | ||
370 | $tmp = []; |
376 | $tmp = []; |
371 | - | ||
372 | foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) { |
377 | foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) { |
- | 378 | if (strpos($author,'ViaThinkSoft') !== false) { |
|
373 | $line = str_pad('HashSpaceUuid<'.htmlentities($friendlyName).'>', 34, ' ', STR_PAD_RIGHT); |
379 | $line = str_pad('HashSpaceUuid<'.htmlentities($friendlyName).'>', 34, ' ', STR_PAD_RIGHT); |
374 | $line .= ':= "'.$space.'".'; |
380 | $line .= ':= "'.$space.'".'; |
375 | if (!$available) $line .= " (Currently not available on this system)"; |
381 | if (!$available) $line .= " (Currently not available on this system)"; |
376 | $line .= "\n"; |
382 | $line .= "\n"; |
377 | - | ||
378 | $tmp[$friendlyName] = $line; |
383 | $tmp[$friendlyName] = $line; |
379 | } |
384 | } |
380 | 385 | } |
|
381 | ksort($tmp); |
386 | ksort($tmp); |
382 | foreach ($tmp as $line) { |
387 | foreach ($tmp as $line) { |
383 | echo $line; |
388 | echo $line; |
384 | } |
389 | } |
385 | 390 |