Skip to content

Commit aeaa5ed

Browse files
authored
Fixes UUIDv7 lack of randomness (#10865)
1 parent c2ccb2d commit aeaa5ed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

std/uuid.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ public struct UUID
318318
/**
319319
* UUID V7 constructor
320320
*
321+
* This implementation is not guaranteed to use a cryptographically secure PRNG.
322+
* For more information please see: std.random.unpredictableSeed
323+
*
321324
* Params:
322325
* timestamp = the timestamp part of the UUID V7
323326
* random = UUID V7 has 74 bits of random data, which rounds to 10 ubyte's.
@@ -1797,7 +1800,7 @@ enum uuidRegex = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}"~
17971800
private ubyte[10] generateV7RandomData() {
17981801
import std.random : Random, uniform, unpredictableSeed;
17991802

1800-
auto rnd = Random(unpredictableSeed!(ubyte)());
1803+
auto rnd = Random(unpredictableSeed);
18011804

18021805
ubyte[10] bytes;
18031806
foreach (idx; 0 .. bytes.length)

0 commit comments

Comments
 (0)