Skip to content

Commit fac8ac1

Browse files
authored
UUIDv7 Draft 3 will simplify node generation (#39)
1 parent 26d947b commit fac8ac1

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/UUID.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ public static function uuid7(): string
217217
$subsec = self::encodeSubsec($subsec);
218218
$uhex = substr(str_pad(dechex($unixts), 9, '0', \STR_PAD_LEFT), -9);
219219
$uhex .= substr_replace(str_pad(dechex($subsec), 6, '0', \STR_PAD_LEFT), '7', -3, 0);
220-
do {
221-
$node = random_bytes(8);
222-
} while ($node === str_repeat(chr(0), 8));
223-
$uhex .= bin2hex($node);
220+
$uhex .= bin2hex(random_bytes(8));
224221
return self::uuidFromHex($uhex, 7);
225222
}
226223

0 commit comments

Comments
 (0)