NetDevPack.Security.PasswordHasher.Argon2 8.0.0

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

Improved PasswordHasher

Nugetcoverage

<img align="right" width="100px" src="docs/helldog-site.png" /> Custom PasswordHasher for ASP.NET Core Identity. There are 3 options: Argon2id, Scrypt and Bcrypt.

A strong password storage strategy is critical to mitigating data breaches that put the reputation of any organization in danger. Hashing is the foundation of secure password storage.

This component auto upgrade your AspNet Identity v2 or v3 password hash to one of these in this package. It does it after a user successfull login

Table of Contents


Why?

ASP.NET Core Identity uses PBKDF2. With HMAC-SHA256. A 128-bit salt. 256-bit subkey and 10.000 iterations. It's FIPS compliant and recommended by NIST. Whilst it's considered good enough, isn't the best choice against newer atack. Such as GPU based.

Wanna know more why Hash password? Read here or here.


Download

The latest stable release of the NetDevPack.Security.PasswordHasher is available at NuGet.

Versions:

Compatibility

Package version Target framework
8.x .NET 10 (LTS)
7.x .NET 8, .NET 9, .NET 10

Hashes created by 7.x are still valid in 8.x. The test suite checks stored Argon2id, scrypt, bcrypt and ASP.NET Identity v2/v3 hashes on every build.


Configure

There are specific configuration for each one of algorithms.

Argon2

Argon2 is the winner of the password hashing competition and should be considered as your first choice for new applications.

Argon2 is cryptographic hashing algorithm, most recommended for password hashing. It is designed by Alex Biryukov, Daniel Dinu, and Dmitry Khovratovich from University of Luxembourg.

This implementation uses libsodium library and it's implementation of Argon2id. Which is considere best option for Password hashing.

    services.AddDefaultIdentity<IdentityUser>();
    services.UpgradePasswordSecurity().UseArgon2<IdentityUser>();

For options (Default is Sensitive, the stronger)

    services.UpgradePasswordSecurity()
                    .WithStrenghten(PasswordHasherStrenght.Interactive)
                    .UseArgon2<IdentityUser>();

Or more advanced options:

    services.UpgradePasswordSecurity()
                    .WithMemLimit(33554432)
                    .WithOpsLimit(4L)
                    .UseArgon2<IdentityUser>();

BCrypt

bcryps was designed by reusing and expanding elements of a block cipher called Blowfish. The iteration count is a power of two, which is a tad less configurable than PBKDF2, but sufficiently so nevertheless. This is the core password hashing mechanism in the OpenBSD operating system.

This implementation uses libsodium library and it's implementation of Argon2id. Which is considere best option for Password hashing.

    services.AddDefaultIdentity<IdentityUser>();
    services.UpgradePasswordSecurity().UseBcrypt<IdentityUser>();

For options

    services.UpgradePasswordSecurity()
                    .ChangeSaltRevision(BcryptSaltRevision.Revision2B) // default: BcryptSaltRevision.Revision2B
                    .ChangeWorkFactor(15) // default: 10
                    .UseBcrypt<IdentityUser>();

Scrypt

scrypt is a much newer construction (designed in 2009) which builds over PBKDF2 and a stream cipher called Salsa20/8, but these are just tools around the core strength of scrypt, which is RAM. scrypt has been designed to inherently use a lot of RAM (it generates some pseudo-random bytes, then repeatedly read them in a pseudo-random sequence). "Lots of RAM" is something which is hard to make parallel. A basic PC is good at RAM access, and will not try to read dozens of unrelated RAM bytes simultaneously. An attacker with a GPU or a FPGA will want to do that, and will find it difficult.

    services.AddDefaultIdentity<IdentityUser>();
    services.UpgradePasswordSecurity().UseScrypt<IdentityUser>();

For options (Default is Sensitive, the stronger)

    services.UpgradePasswordSecurity()
                    .WithStrenghten(PasswordHasherStrenght.Interactive)
                    .UseScrypt<IdentityUser>();

Or more advanced options:

    services.UpgradePasswordSecurity()
                    .WithMemLimit(33554432)
                    .WithOpsLimit(4L)
                    .UseScrypt<IdentityUser>();

Breaking chanegs

The package had a typo in the word "Strenght"; the correct spelling is "Strength". Fixing this bug may have affected some projects. Therefore, if after updating, you see that the method WithStrengthen or others are not found, change them to the ones with "th" instead of "ht".

Playground

Wanna see Argon2, Scrypt or BCrypt in action?


License

NetDevPack.Security.PasswordHasher is Open Source software and is released under the MIT license. This license allow the use of NetDevPack.Security.PasswordHasher in free and commercial applications and libraries without restrictions.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NetDevPack.Security.PasswordHasher.Argon2:

Repository Stars
desenvolvedor-io/dev-store
A microservices e-commerce reference application built with ASP.NET 9
Version Downloads Last Updated
8.0.0 0 11/18/2026
7.1.2 16,202 2/5/2026
7.1.0 26,666 2/8/2024
7.0.1 5,390 3/18/2023
7.0.0 3,185 11/17/2022
6.0.0 14,059 2/27/2022
5.1.1 952 2/27/2022
5.0.5 1,986 5/16/2021

Argon2id-based IPasswordHasher with configurable cost factors, NetDevPack DI extensions, and automatic upgrade path for legacy ASP.NET Identity hashes.