Simple.PasswordGenerator
1.0.8
dotnet add package Simple.PasswordGenerator --version 1.0.8
NuGet\Install-Package Simple.PasswordGenerator -Version 1.0.8
<PackageReference Include="Simple.PasswordGenerator" Version="1.0.8" />
<PackageVersion Include="Simple.PasswordGenerator" Version="1.0.8" />
<PackageReference Include="Simple.PasswordGenerator" />
paket add Simple.PasswordGenerator --version 1.0.8
#r "nuget: Simple.PasswordGenerator, 1.0.8"
#:package Simple.PasswordGenerator@1.0.8
#addin nuget:?package=Simple.PasswordGenerator&version=1.0.8
#tool nuget:?package=Simple.PasswordGenerator&version=1.0.8
Simple.PasswordGenerator
π 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
π¦ 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.RandomNumberGeneratorfor 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 | Versions 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. |
-
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.