Skip to content

A simple .NET Standard library to Generator Random Strings, Great for generating OTP and Passwords.

License

Notifications You must be signed in to change notification settings

lcspinto/StringRandomizer

 
 

Repository files navigation

StringRandomizer

A simple .NET Standard library to Generator Random Strings, Great for generating OTP and Passwords.

Build Status NuGet Badge

Samples

Randomizer by default creates a string with numbers and upper characters of length 10

Basic use,

var randomizer = new Randomizer();
var result = randomizer.Next();
Console.WriteLine(result);  
Output
----------
KI1677784H

Generating strings with lower and upper characters of length 6.

var randomizer = new Randomizer(6, new DefaultRandomizerOptions(hasNumbers: false, hasLowerAlphabets: true, hasUpperAlphabets: true));
var result = randomizer.Next();
Console.WriteLine(result);  
Output
------
meAoQH

Generate 10000 unique non-repeating string of length 5. All the strings will be stored locally. You can use DefaultRandomizerStore or create your own store by implementing IRandomizerStore.

var randomizer = new Randomizer(5, store: new DefaultRandomizerStore());
int i = 0;

while (i < 10000)
{
    Console.WriteLine(randomizer.Next());  
    i++;
}

Generate 10000 unique non-repeating string of length 4 with numbers and lower characters.

var randomizer = new Randomizer(4, new DefaultRandomizerOptions(hasNumbers: true, hasLowerAlphabets: true, hasUpperAlphabets: false),  new DefaultRandomizerStore());

int i = 0;

while (i < 10000)
{
    Console.WriteLine(randomizer.Next());  
    i++;
}

About

A simple .NET Standard library to Generator Random Strings, Great for generating OTP and Passwords.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%