Security Component generateRandomString collision?

Hello,

I’m using the new Security component to generate a random ID for AWS S3 uploaded files key, appending the original file name.

Example:

This is needed because of alphabetical S3 partitions storage (you can google it)

Anyway, the question is, what is the rate of collision in this case? In the real case, nobody will upload millions of files with the same name, but should I consider a different approach?

I was thinking about using generateRandomKey(), uniqid() and base64_encode() but I think it’s not an improvement…

Thank you!

generateRandomString() uses generateRandomKey() which uses /dev/urandom which should be random enough. Better than uniqid().