Josephan.PasswordHashing
1.0.4
dotnet add package Josephan.PasswordHashing --version 1.0.4
NuGet\Install-Package Josephan.PasswordHashing -Version 1.0.4
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="Josephan.PasswordHashing" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Josephan.PasswordHashing" Version="1.0.4" />
<PackageReference Include="Josephan.PasswordHashing" />
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 Josephan.PasswordHashing --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Josephan.PasswordHashing, 1.0.4"
#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 Josephan.PasswordHashing@1.0.4
#: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=Josephan.PasswordHashing&version=1.0.4
#tool nuget:?package=Josephan.PasswordHashing&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🔐 Josephan.PasswordHashing
Lightweight and secure password hashing library for .NET using Argon2id, with clean Dependency Injection support and configurable options.
✨ Features
- 🔒 Secure password hashing using Argon2id
- ⚙️ Fully configurable hashing options
- 🧩 Clean integration with Dependency Injection
- 📦 Lightweight and minimal API surface
- 🛡️ Constant-time password verification (timing attack resistant)
- 📄 PHC string format support (self-contained hash)
📦 Installation
dotnet add package Josephan.PasswordHashing
📖 Usage
Register with default options
// Program.cs — sensible defaults, zero config needed
builder.Services.AddPasswordHashing();
Register with custom options
builder.Services.AddPasswordHashing(options =>
{
options.MemorySize = 65536; // 64 MB
options.Iterations = 3;
options.DegreeOfParallelism = 4;
});
Hash a password
public class AuthService(IPasswordHasher passwordHasher)
{
public string RegisterUser(string plainPassword)
{
// Returns a self-contained PHC string — salt & params embedded:
// $argon2id$v=19$m=65536,t=3,p=4$c2FsdHNhbHRz$hashedvalue...
return passwordHasher.HashPassword(plainPassword);
}
}
Verify a password
public class AuthService(IPasswordHasher passwordHasher)
{
public bool Login(string storedHash, string plainPassword)
{
// Constant-time comparison — safe against timing attacks
bool isValid = passwordHasher.VerifyPassword(storedHash, plainPassword);
if (!isValid)
throw new UnauthorizedAccessException("Invalid credentials.");
return true;
}
}
Full round-trip
// 1. Hash on registration
string hash = passwordHasher.HashPassword("MyS3cur3P@ssword!");
// → "$argon2id$v=19$m=65536,t=3,p=4$..." ← store this in your DB
// 2. Verify on login
bool match = passwordHasher.VerifyPassword(hash, "MyS3cur3P@ssword!"); // true
bool wrong = passwordHasher.VerifyPassword(hash, "WrongPassword"); // false
💡 The PHC string is self-contained — salt, algorithm, and parameters are all embedded in the hash. You never need to store the salt separately.
🐙 GitHub Repository
github.com/yousefyahia828/Josephan.PasswordHashing
📄 License
MIT © Yousef Yahia
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Konscious.Security.Cryptography.Argon2 (>= 1.3.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.