diff options
author | Mario <mario@mariovavti.com> | 2019-12-12 14:51:10 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-12-12 14:51:10 +0000 |
commit | 544ef3bc588d4180d7ecad15bdacd43813a7c5c5 (patch) | |
tree | 62372d0af859287235f62f20d0cf55b5b5b1ace3 /vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php | |
parent | 124cc4396247c75c14280136cfaa95415860ad4c (diff) | |
download | volse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.tar.gz volse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.tar.bz2 volse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.zip |
update composer libs and minor notifications display fixes
Diffstat (limited to 'vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php')
-rw-r--r-- | vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php index 76c570d7f..79ec63cb8 100644 --- a/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php @@ -14,6 +14,7 @@ namespace Ramsey\Uuid\Provider\Node; +use Exception; use Ramsey\Uuid\Provider\NodeProviderInterface; /** @@ -28,15 +29,29 @@ class RandomNodeProvider implements NodeProviderInterface * Returns the system node ID * * @return string System node ID as a hexadecimal string - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws Exception if it was not possible to gather sufficient entropy */ public function getNode() { - $node = hexdec(bin2hex(random_bytes(6))); + $nodeBytes = random_bytes(6); + + // Split the node bytes for math on 32-bit systems. + $nodeMsb = substr($nodeBytes, 0, 3); + $nodeLsb = substr($nodeBytes, 3); // Set the multicast bit; see RFC 4122, section 4.5. - $node = $node | 0x010000000000; + $nodeMsb = hex2bin( + str_pad( + dechex(hexdec(bin2hex($nodeMsb)) | 0x010000), + 6, + '0', + STR_PAD_LEFT + ) + ); + + // Recombine the node bytes. + $node = $nodeMsb . $nodeLsb; - return str_pad(dechex($node), 12, '0', STR_PAD_LEFT); + return str_pad(bin2hex($node), 12, '0', STR_PAD_LEFT); } } |