-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this library able to ensure that UUID_v4 does not conflict? #18
Comments
Fine, I've had the same uuid generated twice on the same day in 4 months. This probability can no longer meet the requirements of uuid. |
I think that depends on the random number generator that you supply. The default isn't necessarily the best, but it does the job most of the time. Though looking at the source code, it uses random_device, which should be 'true random' https://en.cppreference.com/w/cpp/numeric/random/random_device When you got that collision, how did you compare? Was it with a hash? |
UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
UUIDv4::UUID uuid = uuidGenerator.getUUID(); |
std::mt19937_64 is a pseudo random number generator that needs to be sourced with a random number (seed) before it can give you somewhat random numbers. If you want it to be uuid v4 spec, you need to use std::random_device (which is the default if you don't supply a random engine) |
I used this library to generate uuid but found two cases of uuid conflict today. The two uuids I generated on December 1st conflicted with the two uuids on November 18th and 20th.
The text was updated successfully, but these errors were encountered: