ljnath / RandomString4Net

.NET library to generate N random strings of M length from various categories
MIT License
9 stars 2 forks source link
password password-generator password-strength random random-generation random-number-generator random-password-generator randomstring randomstringsgenerator

RandomString4Net

Version 1.8.0

Author : Lakhya Jyoti Nath (ljnath)
Date : September 2020 - December 2022 - January 2023 - October 2023 - November 2023
Email : ljnath@ljnath.com
Website : https://www.ljnath.com

Nuget Nuget GitHub CodeFactor Grade Codecov

Introduction

RandomString4Net 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

Features

Supported Types

Get Started

1. Install Package

PM> Install-Package RandomString4Net

2. Add reference in your project

3. Call the methods in your program

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);
    }
}

Give a Star! ⭐️

If you find this repository useful, please give it a star. Thanks in advance !

License

Copyright © 2020-2023 Lakhya's Innovation Inc. under the MIT License.