


If you cache the one instance, you save about one nano second per invocation. On my i7 laptop, using BenchmarkDotNet (included in the repo), you are looking at ~14 nano seconds to get a string if you just create a StringCreator and call Get. Ideally you should cache one instance of RandomStringCreator and use it throughout, though the actual performance impact on this is very minimal so you probably don't want to bother unless you do this a lot. The implementation uses Windows or OpenSSL Crypto APIs (see Implementation). The only restriction is that characters must all be ASCII characters. Similarly, you could add punctuation etc. Will only return strings with lowercase letters. For example new StringCreator("abcdefghijklmnopqrstuvwxyz") If you want to accept a different set of characters, pass in a string with all valid characters in the constructor. In the simplest case, just instantiate it and call the Create method with a length like this: new StringCreator().Get(6) īy default, the generated string will be limited to upper and lower characters and numbers, though there is no guarantee that all the different types will be present.

Installation Install-Package Install-Package RandomStringCreator It uses crypto APIs, not Random, to avoid any risk of the same string being returned from concurrent invocations, thus making it more suitable for use where you need a higher probability of uniqueness.
WINDOWS GENERATE RANDOM STRING PASSWORD
This package generates random strings that can be used for things like IDs or unique strings in URLs or even password generation.
