PasswordTheBest 2.0.0

dotnet add package PasswordTheBest --version 2.0.0
                    
NuGet\Install-Package PasswordTheBest -Version 2.0.0
                    
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="PasswordTheBest" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PasswordTheBest" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PasswordTheBest" />
                    
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 PasswordTheBest --version 2.0.0
                    
#r "nuget: PasswordTheBest, 2.0.0"
                    
#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.
#addin nuget:?package=PasswordTheBest&version=2.0.0
                    
Install PasswordTheBest as a Cake Addin
#tool nuget:?package=PasswordTheBest&version=2.0.0
                    
Install PasswordTheBest as a Cake Tool

PasswordTheBest 🔒

PasswordTheBest is the best password library for .NET. It provides password validation and password hashing to help you follow the best password practices. Advanced password security toolkit with multiple hashing implementations

🔐 Supported Algorithms

Class Algorithm Security Ideal For
PasswordHash256Salt PBKDF2-SHA256 High Most web applications
PasswordHash512Salt PBKDF2-SHA512 Very High Financial systems

⚠️ Legacy Support Only

Class Algorithm Status Risk Level
PasswordHashSHA1Salt PBKDF2-SHA1 Deprecated Critical Security Risk
PasswordHashMD5Salt MD5 Broken Extreme Vulnerability

Getting Started

Prerequisites

  • .NET 6.0 SDK or later

Installation

You can install the PasswordTheBest library via NuGet Package Manager:

dotnet add package PasswordTheBest

Usage

Password Validation

To validate a password, use the CPasswordValidation class:

using PasswordTheBest.Validations;

CPasswordValidation cPasswordValidation = CPasswordValidation.Create(password, new CProperties
{
    Minimum = 6,
    IsAtLeastOneDigit = true,
    IsAtLeastOneSpecialCharacter = true
});

    bool resultActual = cPasswordValidation.ValidPassword();
Password Hashing

Simple for implement:

using PasswordTheBest;

var password = "password";

var passwordHasher = PasswordTheBestFactory.Create(HashAlgorithmName.SHA256);

var hash = passwordHasher.Hash(password, out string salt);

🛡️ Password Strength Analysis

// Example: Enforce strong passwords
var analyzer = new PasswordStrengthAnalyzer();
if (analyzer.Analyze(userPassword) < PasswordStrength.Strong)
{
    // Require better password
}

Metrics Checked:

  • Length (12+ chars recommended)
  • Character diversity (upper/lower/numeric/special)
  • Common password patterns
  • Repeated characters
  • Mixed case and special char combinations

🔐 Best Practices for Password Security

1. Algorithm Selection

  • Recommended: PasswordHash512Salt (PBKDF2-SHA512)
  • Acceptable: PasswordHash256Salt (PBKDF2-SHA256)
  • Deprecated: PasswordHashSHA1Salt (Only for legacy systems)
  • Forbidden: PasswordHashMD5Salt (Never use in production)

2. Configuration Guidelines

Parameter Minimum Value Recommended Value Notes
Iterations 100,000 350,000 Adjust based on server load
Salt Size 16 bytes 32 bytes Must be cryptographically random
Hash Output 32 bytes 64 bytes Longer = more collision-resistant

3. Implementation Checklist

// ✔️ DO THIS:
var secureHasher = new PasswordHash512Salt(
    hashSize: 64,
    saltSize: 32,
    iterations: 350000
);

// ❌ AVOID THIS:
var weakHasher = new PasswordHashMD5Salt(); // Vulnerable to rainbow tables

4. Storage Requirements

  • Always store:
    • The hash (Base64 encoded)
    • The salt (Base64 encoded)
    • Algorithm version/parameters
  • Never store:
    • Plaintext passwords
    • Unsalted hashes
    • Weak algorithm indicators (e.g., "MD5")

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net6.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
2.0.0 144 4/18/2025
1.0.0 137 1/25/2025