Simple.PasswordGenerator 1.0.8

dotnet add package Simple.PasswordGenerator --version 1.0.8
                    
NuGet\Install-Package Simple.PasswordGenerator -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Simple.PasswordGenerator" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Simple.PasswordGenerator" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Simple.PasswordGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Simple.PasswordGenerator --version 1.0.8
                    
#r "nuget: Simple.PasswordGenerator, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Simple.PasswordGenerator@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Simple.PasswordGenerator&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Simple.PasswordGenerator&version=1.0.8
                    
Install as a Cake Tool

Simple.PasswordGenerator

GitHub Repo stars
GitHub Actions Workflow Status
NuGet version
NuGet Downloads
GitHub Issues


πŸš€ Overview

Simple.PasswordGenerator is a lightweight, secure password generator for .NET applications.
It creates cryptographically strong passwords based on customizable policies β€” including length, required character types, special characters, and the ability to exclude ambiguous characters for better readability.

No dependencies beyond .NET. Simple to integrate, flexible to configure, and safe to use.


πŸ”‘ Key Features

  • πŸ” Cryptographically secure password generation
  • βš™οΈ Fully customizable policies (length, uppercase, lowercase, digits, special chars, ambiguous character exclusion)
  • 🎯 Default policy with sensible security defaults
  • πŸ”„ Supports configuration via lambda or predefined policy objects
  • 🧩 Provides password strength estimation including entropy calculation
  • πŸ”€ Uses Fisher–Yates shuffle for password character randomization
  • 🧩 Compatible with .NET 8 and later

πŸ“š Table of Contents

  1. Getting Started
  2. Examples
  3. Technical Information
  4. Known Issues & Limitations
  5. Contributing
  6. License

🚦 Getting Started

Use Simple.PasswordGenerator to generate strong, policy-compliant passwords easily.

πŸ“¦ Installing

Add the package via NuGet:

dotnet add package Simple.PasswordGenerator

πŸ§ͺ Basic Usage

var generator = new PasswordGenerator();
var password = generator.Generate();
Console.WriteLine($"Generated password: {password}");

🎯 Advanced Usage

Configure a custom password policy using a lambda:

var password = generator.Generate(policy =>
{
    policy.Length = 20;
    policy.RequireSpecial = false;
    policy.RequireDigit = true;
    policy.RequireUppercase = true;
    policy.RequireLowercase = true;
    policy.ExcludeAmbiguousCharacters = true;
});

Or generate using a predefined PasswordPolicy object:

var policy = new PasswordPolicy
{
    Length = 12,
    RequireSpecial = true,
    RequireDigit = true,
    RequireUppercase = false,
    RequireLowercase = true,
    SpecialCharacters = "@#$",
    ExcludeAmbiguousCharacters = true,
    AmbiguousCharacters = "O0Il1"
};
var passwordFromPolicy = generator.Generate(policy);

πŸ“Š Generating Password with Strength Info

You can generate a password and receive detailed strength information including entropy and strength category:

var strengthResult = generator.GenerateWithStrength(policy =>
{
    policy.Length = 16;
    policy.RequireUppercase = true;
    policy.RequireLowercase = true;
    policy.RequireDigit = true;
    policy.RequireSpecial = true;
});

Console.WriteLine($"Password: {strengthResult.Password}");
Console.WriteLine($"Entropy (bits): {strengthResult.EntropyBits}");
Console.WriteLine($"Strength: {strengthResult.Strength}");

πŸ–ΌοΈ Examples

using Simple.PasswordGenerator;

var passwordGenerator = new PasswordGenerator();

// Default policy password
var defaultPassword = passwordGenerator.Generate();
Console.WriteLine($"Default policy password: {defaultPassword}");

// Custom policy via lambda
var customPassword = passwordGenerator.Generate(policy =>
{
    policy.Length = 20;
    policy.RequireSpecial = false;
    policy.RequireDigit = true;
    policy.RequireUppercase = true;
    policy.RequireLowercase = true;
    policy.ExcludeAmbiguousCharacters = true;
});
Console.WriteLine($"Custom policy password: {customPassword}");

// Using a PasswordPolicy instance
var policyInstance = new PasswordPolicy
{
    Length = 12,
    RequireSpecial = true,
    RequireDigit = true,
    RequireUppercase = false,
    RequireLowercase = true,
    SpecialCharacters = "@#$",
    ExcludeAmbiguousCharacters = true,
    AmbiguousCharacters = "O0Il1"
};
var policyPassword = passwordGenerator.Generate(policyInstance);
Console.WriteLine($"Password from policy instance: {policyPassword}");

// Generate password with strength info
var strengthResult = passwordGenerator.GenerateWithStrength(policy =>
{
    policy.Length = 16;
    policy.RequireUppercase = true;
    policy.RequireLowercase = true;
    policy.RequireDigit = true;
    policy.RequireSpecial = true;
});
Console.WriteLine($"Password: {strengthResult.Password}");
Console.WriteLine($"Entropy (bits): {strengthResult.EntropyBits}");
Console.WriteLine($"Strength: {strengthResult.Strength}");

πŸ”¬ Technical Information

  • Uses System.Security.Cryptography.RandomNumberGenerator for cryptographically secure randomization
  • Password policy validation ensures minimum length and required character types
  • Supports exclusion of ambiguous characters (e.g., 'O', '0', 'I', 'l', '1') to improve password readability
  • Character categories: uppercase, lowercase, digits, special characters, and additional custom characters
  • Password characters are shuffled with the Fisher–Yates algorithm for unpredictability
  • Provides entropy calculation and password strength classification based on entropy

🐞 Known Issues & Limitations

  • No known issues at this time

🀝 Contributing

Bug reports, feature requests, and pull requests are welcome!
Please open an issue or submit a PR via GitHub Issues.


πŸ“„ License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 909 7/14/2025
1.0.7 877 7/14/2025
1.0.6 878 7/14/2025
1.0.5 889 7/14/2025
1.0.4 881 7/14/2025
1.0.3 883 7/14/2025