r-lyeh-archived / sole

:doughnut: Sole is a lightweight C++11 library to generate universally unique identificators (UUID), both v1 and v4.
zlib License
296 stars 75 forks source link

uuid4 seems unsafe base on C++ standards #19

Open DJHoltkamp opened 6 years ago

DJHoltkamp commented 6 years ago

I have found the following content on std::random_device:

std::random_device is a uniformly-distributed integer random number generator that produces non-deterministic random numbers. std::random_device may be implemented in terms of an implementation-defined pseudo-random number engine if a non-deterministic source (e.g. a hardware device) is not available to the implementation. In this case each std::random_device object may generate the same number sequence.

I am writing a cross platform game and wanting a good UUID, and the fact that these could come out as the same number on some devices (I am thinking Android in particular) is a bit terrifying. Please let me know if I am wrong and there is a better assurance that this couldn't happen.

dan-ryan commented 6 years ago

Looks like this could be a problem. More info: https://stackoverflow.com/questions/45069219/how-to-succinctly-portably-and-thoroughly-seed-the-mt19937-prng