codeyu / nanoid-net

.NET implementation of ai's nanoid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Each new instance of CryptoRandom replaces the static generator.

sloncho opened this issue · comments

_r = RandomNumberGenerator.Create();

Not sure if this is a problem or not, but looks like it can have negative consequences. The CryptoRandom is used as singleton in NanoId static class, but as CryptoRandom is public, the consumer can create new instances, which in term will replace the static _r member, this changing the behavior of the instance used in Nanoid static methods.

Suggestion: make _r instance, and not static field. Or use static initializer on L19 instead of constructor initializer.

Fixed in #14

thank you. v3.1.0 released.