A library which generates random passwords with different settings to meet the OWASP requirements
C#
Permalink
Failed to load latest commit information.
PasswordGenerator
UnitTests
packages/NUnit.3.5.0
.gitattributes 🍭 Added .gitattributes Nov 11, 2016
.gitignore
License.md added readmes and nuspec file Nov 11, 2016
PasswordGenerator.nuspec added readmes and nuspec file Nov 11, 2016
PasswordGenerator.sln added tests Nov 12, 2016
Readme.md Updated readme Nov 16, 2016
appveyor.yml added appveyor.yml file Nov 12, 2016
pg_logo.png

Readme.md

PasswordGenerator Logo

A library which generates random passwords with different settings to meet the OWASP requirements

NuGet

Install via NuGet: Install-Package PasswordGenerator

Or click here to go to the package landing page

Basic usage

See examples below or try them out now in your browser using Dotnetfiddle

// By default, all characters available for use and a length of 16
// Will return a random password with the default settings 
PasswordGenerator pwdGen = new PasswordGenerator();
string password = pwdGen.Next();
// Same as above but you can set the length. Must be between 8 and 128
// Will return a password which is 32 characters long
PasswordGenerator pwdGen = new PasswordGenerator(32);
string password = pwdGen.Next();
// Same as above but you can set the length. Must be between 8 and 128
// Will return a password which only contains lowercase and uppercase characters and is 21 characters long.
PasswordGenerator pwdGen = new PasswordGenerator(includeLowercase: true, includeUppercase: true, includeNumeric: false, includeSpecial: false, passwordLength: 21);
string password = pwdGen.Next();

Fluent usage

// You can build up your reqirements by adding things to the end, like .AddNumeric()
// This will return a password which is just numbers and has a default length of 16
PasswordGenerator pwdGen = new PasswordGenerator().IncludeNumeric();
string password = pwdGen.Next();
// As above, here is how to get lower, upper and special characters using this approach
PasswordGenerator pwdGen = new PasswordGenerator().IncludeLowercase().IncludeUppercase().IncludeSpecial();
string password = pwdGen.Next();
// This is the same as the above, but with a length of 128
PasswordGenerator pwdGen = new PasswordGenerator(128).IncludeLowercase().IncludeUppercase().IncludeSpecial();
string password = pwdGen.Next();
// This is the same as the above, but with passes the length in using the method LengthRequired()
PasswordGenerator pwdGen = new PasswordGenerator().IncludeLowercase().IncludeUppercase().IncludeSpecial().LengthRequired(128);
string password = pwdGen.Next();