UUID
Version 4 or version 7, one at a time or a thousand at once.
Result
Good to know
- v4 is 122 random bits and nothing else. Two of them colliding is not something that happens: you would need to generate a billion a second for 85 years to reach a one in a billion chance.
- v7 puts the millisecond it was made at the front, so a column of them sorts by time. That is what makes it a better database key than v4, whose randomness scatters writes across the index.
- The flip side is that v7 tells anyone holding it when the row was created, to the millisecond. If that is a leak in your case, v4 is the one that says nothing.
- The randomness comes from the browser's own cryptographic source, never from Math.random. Nothing is generated on the server and nothing is sent to it.
25 views