You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This is an alternative version of a randomly generated UUID, using both the timestamp and pseudo-random bytes.
6
+
* Maybe I'm wrong about all that but I thought mixing the UUID v1 and v4 methods would make the generated UUID more secure, as it ensures a zero-chance of collision of a single computer and a -really- low chance of collision on multiple computers (because of both probability and time).
7
+
* The UUID contains 62 randomly generated bits, so there is 2^62 different outcomes for that part of the generated UUID, which means you'd start geeting colisions after about 2^31 generations. That being said, that would only happen if you were able to generate that many UUIDs within 100 nanosecond to 1 microsecond (because the gettimeofday() function used here returns a microsecond-precise timestamp).
8
+
*
9
+
* This generated UUID format is {oooooooo-oooo-Mooo-Nxxx-xxxxxxxxxxxx}, it concatenates:
10
+
* - o: The current timestamp (60 bits) (time_low, time_mid, time_high)
11
+
* - M: The version (4 bits)
12
+
* - N: The variant (2 bits)
13
+
* - x: Pseudo-random values (62 bits)
14
+
*
15
+
* Based on:
16
+
* - Code from an UUID v1 Generation script. https://github.com/fredriklindberg/class.uuid.php/blob/c1de11110970c6df4f5d7743a11727851c7e5b5a/class.uuid.php#L220
17
+
* - Code from an UUID v4 Generation script. https://stackoverflow.com/a/15875555/5255556
0 commit comments