moonpyk / ncuid

Collision-resistant ids for .NET (port of https://github.com/dilvie/cuid)
MIT License
36 stars 13 forks source link

Creating a new instance of Random every time can lead to identical output #1

Open sbrl opened 6 years ago

sbrl commented 6 years ago

At https://github.com/moonpyk/ncuid/blob/master/NCuid/Cuid.cs#L104, you create a new instance of Random every time the method is called. If I call it in a loop very quickly, then that part of the cuid won't be truly random, as C♯ / .NET seeds Random with the system's clock.

Consider making Random a private static member of the class itself.

moonpyk commented 6 years ago

This is totaly true, I'll fix that