.NET library to generate random strings. This package is based on the original RandomString4Net package by Lakhya Jyoti Nath.
$ dotnet add package DotNetRandomStringGeneratorAuthors : Jeff Shergalis Lakhya Jyoti Nath (ljnath)
Date : September 2020 - October 2024
DotNetRandomStringGenerator is a library developed in .NET Framework to generate N random strings of M length from various categories. It is fast and suports string generation of various length.
It is parameterized to generate both a single or a list of random strings.
Random strings can be of types alphabet and alphanumeric supporting all the cases viz. lower, upper and mixed.
It also supports symbol during the random string generation process. Following are the list of supported symbols
!#$%&'()*+,-./:;<=>?@[]^_`{|}~"
It also allows you to generate random string with only a subset of symbols from the above supported list. It is an ideal use for project like
PM> Install-Package DotNetRandomStringGenerator
using RandomString4Net;
namespace RandomString4NetTester
{
public void Main()
{
// generating one random string from lowercase alphabets
string randomString = RandomString.GetString(Types.ALPHABET_LOWERCASE);
System.Console.WriteLine(randomString);
// generating 100 random string from all mixedcase alphabet, numbers and all supported symbols
List<string> randomAlphaNumbericStrings = RandomString.GetStrings(Types.ALPHANUMERIC_MIXEDCASE_WITH_SYMBOLS, 100);
foreach (string s in randomAlphaNumbericStrings)
System.Console.WriteLine(s);
// generating 200 random string from uppercase alphabet with custom symbols
List<string> randomAlphabetWithCustomSymbols = RandomString.GetStrings(Types.ALPHABET_UPPERCASE, 200, "/+*-");
foreach (string s in randomAlphabetWithCustomSymbols)
System.Console.WriteLine(s);
// generating 1000 true random strings of length 20 from uppercase alphabet with custom symbols
List<string> trueUniqueRandomStrings = RandomString.GetStrings(Types.ALPHABET_UPPERCASE, 1000, 20, false, true);
foreach (string s in trueUniqueRandomStrings)
System.Console.WriteLine(s);
// generating 100 random string of mixedcase alphanummeric with custom symbols
List<string> randomAlphabetWithCustomSymbols = RandomString.GetStrings(Types.ALPHANUMERIC_MIXEDCASE_WITH_SYMBOLS, 100, "/+*-", forceOccuranceOfEachType: true);
foreach (string s in randomAlphabetWithCustomSymbols)
System.Console.WriteLine(s);
}
}
If you find this repository useful, please give it a star. Thanks in advance !
Copyright © 2024 Stuce Software Solutions under the MIT License.