简体   繁体   中英

Does ramsey/uuid version 4 use "true" or pseudo-random numbers?

I'm using ramsey/uuid in my project. I'm creating new data entities with uuid4, which generates random UUIDs:

Uuid::uuid4();

But I'm using this approach while bulk importing many thousands of data too. Now I'm worrying about the entropy pool of my system: does uuid4 use a "true" random number which will deplete my entropy pool at some time? Or will it use pseudo-random numbers and I don't have to worry about?

Thanks a lot!

By default, it generates UUIDs from the random_bytes() function in PHP 7, or the polyfill from the paragonie/random_compat library in PHP 5. So its UUIDs are as random as the response from those functions. See the RandomBytesGenerator class .

It depends what you're doing with the UUIDs as to whether that randomness is good enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM