Skip to content

Commit

Permalink
UUIDv7 Draft 3 will simplify node generation (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
oittaa authored Jan 30, 2022
1 parent 26d947b commit fac8ac1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/UUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,7 @@ public static function uuid7(): string
$subsec = self::encodeSubsec($subsec);
$uhex = substr(str_pad(dechex($unixts), 9, '0', \STR_PAD_LEFT), -9);
$uhex .= substr_replace(str_pad(dechex($subsec), 6, '0', \STR_PAD_LEFT), '7', -3, 0);
do {
$node = random_bytes(8);
} while ($node === str_repeat(chr(0), 8));
$uhex .= bin2hex($node);
$uhex .= bin2hex(random_bytes(8));
return self::uuidFromHex($uhex, 7);
}

Expand Down

0 comments on commit fac8ac1

Please sign in to comment.