diff --git a/src/.dockerignore b/.dockerignore
similarity index 100%
rename from src/.dockerignore
rename to .dockerignore
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..808f9eb
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = crlf
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+trim_trailing_whitespace = true
+
+[*.{cs,csproj,props,targets,sln}]
+charset = utf-8-bom
+
+[*.{json,yml,yaml}]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..aac1598
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,23 @@
+version: 2
+updates:
+ - package-ecosystem: nuget
+ directory: /
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 10
+ commit-message:
+ prefix: chore
+ include: scope
+ groups:
+ tests:
+ patterns: ["xunit*", "AwesomeAssertions"]
+ ignore:
+ # Never reintroduce FluentAssertions (commercial license since v8)
+ - dependency-name: "FluentAssertions"
+
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: ci
diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml
index cd9e894..ee6f3e3 100644
--- a/.github/workflows/publish-package.yml
+++ b/.github/workflows/publish-package.yml
@@ -5,9 +5,13 @@ on:
branches: [ master ]
env:
- REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
CURRENT_REPO_URL: https://github.com/${{ github.repository }}
+permissions:
+ contents: write
+ issues: write
+ pull-requests: write
+
jobs:
publish:
runs-on: ubuntu-latest
@@ -17,34 +21,39 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 0
- - name: Setup .NET SDKs
- uses: actions/setup-dotnet@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v5
with:
- dotnet-version: |
- 8.0.x
- 9.0.x
- 10.0.x
-
+ global-json-file: global.json
+
- name: Restore dependencies
- run: dotnet restore
+ run: dotnet restore
- name: Build
- run: dotnet build --no-restore
+ run: dotnet build --no-restore -c Release
+
+ - name: Test
+ run: dotnet test --no-build -c Release
- name: Semantic Release
id: semantic
- uses: cycjimmy/semantic-release-action@v3
+ uses: cycjimmy/semantic-release-action@v4
with:
+ semantic_version: 24
extra_plugins: |
- @semantic-release/changelog
- @semantic-release/git
+ @semantic-release/changelog@6
+ @semantic-release/git@10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Package
- run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
+ if: steps.semantic.outputs.new_release_published == 'true'
+ run: dotnet pack -c Release -o out -p:Version=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{ env.CURRENT_REPO_URL }}
- name: Publish the package to nuget.org
- run: dotnet nuget push ./out/*.nupkg -n -d -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
+ if: steps.semantic.outputs.new_release_published == 'true'
+ run: dotnet nuget push ./out/*.nupkg --skip-duplicate -k ${{ secrets.NUGET_AUTH_TOKEN }} -s https://api.nuget.org/v3/index.json
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 3b8172e..76499a2 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -1,9 +1,12 @@
-name: Pull Request Analisys
+name: Pull Request Analysis
on:
pull_request:
branches: [ master ]
+permissions:
+ contents: read
+
jobs:
build:
runs-on: ubuntu-latest
@@ -13,21 +16,25 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 0
- - name: Setup .NET SDKs
- uses: actions/setup-dotnet@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v5
with:
- dotnet-version: |
- 8.0.x
- 9.0.x
- 10.0.x
-
+ global-json-file: global.json
+
- name: Restore dependencies
run: dotnet restore
- name: Build
- run: dotnet build --no-restore
+ run: dotnet build --no-restore -c Release
- name: Test
- run: dotnet test --no-build
+ run: dotnet test --no-build -c Release
+
+ - name: Check vulnerable packages
+ run: |
+ dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerable.txt
+ ! grep -q "has the following vulnerable packages" vulnerable.txt
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..a5c8809
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,11 @@
+
+
+
+ latest
+
+ true
+ all
+ $(WarningsAsErrors);NU1901;NU1902;NU1903;NU1904
+ true
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 0000000..65672f3
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,34 @@
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
index 5ed67b2..e1cd4f8 100644
Binary files a/README.md and b/README.md differ
diff --git a/global.json b/global.json
new file mode 100644
index 0000000..1d364c6
--- /dev/null
+++ b/global.json
@@ -0,0 +1,9 @@
+{
+ "sdk": {
+ "version": "10.0.100",
+ "rollForward": "latestFeature"
+ },
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ }
+}
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 0000000..f96372d
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,27 @@
+
+
+
+
+
+ net10.0
+ brunobritodev
+ NetDevPack
+ en
+ MIT
+ https://github.com/NetDevPack/Security.PasswordHasher
+ git
+ master
+ https://github.com/NetDevPack/Security.PasswordHasher
+ icon.png
+ README.md
+
+ true
+ snupkg
+ true
+
+
+
+
+
+
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Argon2/Argon2id.cs b/src/NetDevPack.Security.PasswordHasher.Argon2/Argon2id.cs
index 1b168bc..b48f12f 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Argon2/Argon2id.cs and b/src/NetDevPack.Security.PasswordHasher.Argon2/Argon2id.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Argon2/Extensions/Argon2Extensions.cs b/src/NetDevPack.Security.PasswordHasher.Argon2/Extensions/Argon2Extensions.cs
index d5bb326..c899c49 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Argon2/Extensions/Argon2Extensions.cs and b/src/NetDevPack.Security.PasswordHasher.Argon2/Extensions/Argon2Extensions.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Argon2/NetDevPack.Security.PasswordHasher.Argon2.csproj b/src/NetDevPack.Security.PasswordHasher.Argon2/NetDevPack.Security.PasswordHasher.Argon2.csproj
index 4a13f63..749d057 100644
--- a/src/NetDevPack.Security.PasswordHasher.Argon2/NetDevPack.Security.PasswordHasher.Argon2.csproj
+++ b/src/NetDevPack.Security.PasswordHasher.Argon2/NetDevPack.Security.PasswordHasher.Argon2.csproj
@@ -1,40 +1,17 @@
-
-
+
- net8.0;net9.0;net10.0
- 3.0.0
- brunobritodev
- NetDevPack
argon2;argon2id;identity;aspnetcore;password-hashing;security;cryptography;libsodium;netdevpack
Argon2id password hasher for ASP.NET Core Identity
ASP.NET Core Identity IPasswordHasher implementation backed by libsodium Argon2id.
Supports configurable opslimit/memlimit or strength presets through NetDevPack builder options.
Detects ASP.NET Identity v2/v3 hashes and rehashes them to Argon2id after successful verification.
Argon2id-based IPasswordHasher with configurable cost factors, NetDevPack DI extensions, and automatic upgrade path for legacy ASP.NET Identity hashes.
- en
- MIT
- https://github.com/NetDevPack/Security.PasswordHasher
- git
- main
- https://github.com/NetDevPack/Security.PasswordHasher
- icon.png
-
- true
- snupkg
- true
- true
- latest
-
-
-
-
-
-
-
+
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Bcrypt/BCrypt.cs b/src/NetDevPack.Security.PasswordHasher.Bcrypt/BCrypt.cs
index 8a86bac..320d9af 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Bcrypt/BCrypt.cs and b/src/NetDevPack.Security.PasswordHasher.Bcrypt/BCrypt.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Bcrypt/Extensions/BCryptConfig.cs b/src/NetDevPack.Security.PasswordHasher.Bcrypt/Extensions/BCryptConfig.cs
index 5e28a8e..0701f57 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Bcrypt/Extensions/BCryptConfig.cs and b/src/NetDevPack.Security.PasswordHasher.Bcrypt/Extensions/BCryptConfig.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Bcrypt/NetDevPack.Security.PasswordHasher.Bcrypt.csproj b/src/NetDevPack.Security.PasswordHasher.Bcrypt/NetDevPack.Security.PasswordHasher.Bcrypt.csproj
index 2d8e6d8..0daf4bd 100644
--- a/src/NetDevPack.Security.PasswordHasher.Bcrypt/NetDevPack.Security.PasswordHasher.Bcrypt.csproj
+++ b/src/NetDevPack.Security.PasswordHasher.Bcrypt/NetDevPack.Security.PasswordHasher.Bcrypt.csproj
@@ -1,40 +1,17 @@
-
-
+
- net8.0;net9.0;net10.0
- 3.0.0
- brunobritodev
- NetDevPack
bcrypt;identity;aspnetcore;password-hashing;security;cryptography;netdevpack
BCrypt password hasher for ASP.NET Core Identity
ASP.NET Core Identity IPasswordHasher built on BCrypt.Net.
Lets you tune work factor and salt revision through NetDevPack builder options.
Recognizes ASP.NET Identity v2/v3 hashes and rehashes them with bcrypt after successful verification.
BCrypt-based IPasswordHasher with configurable work factor and salt revision, NetDevPack DI extensions, and automatic upgrade of legacy ASP.NET Identity hashes.
- en
- MIT
- https://github.com/NetDevPack/Security.PasswordHasher
- git
- main
- https://github.com/NetDevPack/Security.PasswordHasher
- icon.png
-
- true
- snupkg
- true
- true
- latest
-
-
-
-
-
-
-
+
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/BcryptSaltRevision.cs b/src/NetDevPack.Security.PasswordHasher.Core/BcryptSaltRevision.cs
index 442627e..e4da37d 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/BcryptSaltRevision.cs and b/src/NetDevPack.Security.PasswordHasher.Core/BcryptSaltRevision.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/IPasswordHashBuilder.cs b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/IPasswordHashBuilder.cs
index 392775a..4702616 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/IPasswordHashBuilder.cs and b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/IPasswordHashBuilder.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherBuilder.cs b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherBuilder.cs
index 3a0959d..dc6c1ec 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherBuilder.cs and b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherBuilder.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherServiceExtensions.cs b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherServiceExtensions.cs
index 07b85ba..43f40ee 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherServiceExtensions.cs and b/src/NetDevPack.Security.PasswordHasher.Core/DependencyInjection/PasswordHasherServiceExtensions.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/ImprovedPasswordHasherOptions.cs b/src/NetDevPack.Security.PasswordHasher.Core/ImprovedPasswordHasherOptions.cs
index a079383..1e2add6 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/ImprovedPasswordHasherOptions.cs and b/src/NetDevPack.Security.PasswordHasher.Core/ImprovedPasswordHasherOptions.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/NetDevPack.Security.PasswordHasher.Core.csproj b/src/NetDevPack.Security.PasswordHasher.Core/NetDevPack.Security.PasswordHasher.Core.csproj
index ec6ecb8..74997ee 100644
--- a/src/NetDevPack.Security.PasswordHasher.Core/NetDevPack.Security.PasswordHasher.Core.csproj
+++ b/src/NetDevPack.Security.PasswordHasher.Core/NetDevPack.Security.PasswordHasher.Core.csproj
@@ -1,47 +1,24 @@
-
-
+
- net8.0;net9.0;net10.0
- 2.0.0
- brunobritodev
- NetDevPack
password-hashing;security;identity;aspnetcore;cryptography;dependency-injection;netdevpack;options
Core library for NetDevPack PasswordHasher
Core abstractions shared by NetDevPack password hashing algorithms for ASP.NET Core Identity.
Provides options and builder extensions to tune work factor, salt revision, and memory/ops limits.
Includes utilities to detect legacy ASP.NET Identity hashes for smoother upgrades.
Provides shared options, DI builder, and hash format detection used by NetDevPack Argon2, BCrypt, and Scrypt password hashers.
- en
- MIT
- https://github.com/NetDevPack/Security.PasswordHasher
- git
- main
- https://github.com/NetDevPack/Security.PasswordHasher
- icon.png
-
- true
- snupkg
- true
- true
- latest
-
-
+
+
-
-
-
-
-
-
+
<_CustomFiles Include="../../.github/hooks/commit-msg" />
-
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Core/PasswordHasherStrength.cs b/src/NetDevPack.Security.PasswordHasher.Core/PasswordHasherStrength.cs
index 402c616..3cc5f62 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Core/PasswordHasherStrength.cs and b/src/NetDevPack.Security.PasswordHasher.Core/PasswordHasherStrength.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Identity.Demo/Dockerfile b/src/NetDevPack.Security.PasswordHasher.Identity.Demo/Dockerfile
index 7b1b424..d04e282 100644
--- a/src/NetDevPack.Security.PasswordHasher.Identity.Demo/Dockerfile
+++ b/src/NetDevPack.Security.PasswordHasher.Identity.Demo/Dockerfile
@@ -1,4 +1,5 @@
-#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
+# Build context is the repository root (Directory.Build.props, Directory.Packages.props, global.json):
+# docker build -f src/NetDevPack.Security.PasswordHasher.Identity.Demo/Dockerfile .
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
@@ -6,11 +7,11 @@ EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
-WORKDIR /src
-COPY ["NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj", "NetDevPack.Security.PasswordHasher.Identity.Demo/"]
-RUN dotnet restore "NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj"
-COPY . .
-WORKDIR "/src/NetDevPack.Security.PasswordHasher.Identity.Demo"
+WORKDIR /repo
+COPY ["Directory.Build.props", "Directory.Packages.props", "global.json", "icon.png", "README.md", "./"]
+COPY ["src/", "src/"]
+RUN dotnet restore "src/NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj"
+WORKDIR "/repo/src/NetDevPack.Security.PasswordHasher.Identity.Demo"
RUN dotnet build "NetDevPack.Security.PasswordHasher.Identity.Demo.csproj" -c Release -o /app/build -f net10.0
FROM build AS publish
diff --git a/src/NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj b/src/NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj
index 404f8d3..ab759b4 100644
--- a/src/NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj
+++ b/src/NetDevPack.Security.PasswordHasher.Identity.Demo/NetDevPack.Security.PasswordHasher.Identity.Demo.csproj
@@ -1,42 +1,23 @@
-
-
+
- net8.0;net9.0;net10.0
enable
enable
false
-
-
-
- 8.0.23
- 8.0.23
- 8.0.23
-
-
-
- 9.0.12
- 9.0.12
- 9.0.12
-
-
-
- 10.0.2
- 10.0.2
- 10.0.2
+ false
+ ..\..
-
-
-
-
-
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Scrypt/Extensions/ScryptConfig.cs b/src/NetDevPack.Security.PasswordHasher.Scrypt/Extensions/ScryptConfig.cs
index 369ffca..4653ba1 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Scrypt/Extensions/ScryptConfig.cs and b/src/NetDevPack.Security.PasswordHasher.Scrypt/Extensions/ScryptConfig.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.Scrypt/NetDevPack.Security.PasswordHasher.Scrypt.csproj b/src/NetDevPack.Security.PasswordHasher.Scrypt/NetDevPack.Security.PasswordHasher.Scrypt.csproj
index ef9d4ee..1f013f3 100644
--- a/src/NetDevPack.Security.PasswordHasher.Scrypt/NetDevPack.Security.PasswordHasher.Scrypt.csproj
+++ b/src/NetDevPack.Security.PasswordHasher.Scrypt/NetDevPack.Security.PasswordHasher.Scrypt.csproj
@@ -1,40 +1,17 @@
-
-
+
- net8.0;net9.0;net10.0
- 3.0.0
- brunobritodev
- NetDevPack
scrypt;identity;aspnetcore;password-hashing;security;cryptography;libsodium;netdevpack
Scrypt password hasher for ASP.NET Core Identity
ASP.NET Core Identity IPasswordHasher implementation using libsodium scrypt.
Offers strength presets and custom opslimit/memlimit settings through NetDevPack builder options.
Detects ASP.NET Identity v2/v3 hashes and promotes them to scrypt after successful verification.
Scrypt-based IPasswordHasher with configurable memory/time cost, NetDevPack DI integration, and automatic upgrade support for legacy ASP.NET Identity hashes.
- en
- MIT
- https://github.com/NetDevPack/Security.PasswordHasher
- git
- main
- https://github.com/NetDevPack/Security.PasswordHasher
- icon.png
-
- true
- snupkg
- true
- true
- latest
-
-
-
-
-
-
-
+
+
diff --git a/src/NetDevPack.Security.PasswordHasher.Scrypt/Scrypt.cs b/src/NetDevPack.Security.PasswordHasher.Scrypt/Scrypt.cs
index c281b4a..e674dad 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.Scrypt/Scrypt.cs and b/src/NetDevPack.Security.PasswordHasher.Scrypt/Scrypt.cs differ
diff --git a/src/NetDevPack.Security.PasswordHasher.sln b/src/NetDevPack.Security.PasswordHasher.sln
index b18aafc..3056e2c 100644
Binary files a/src/NetDevPack.Security.PasswordHasher.sln and b/src/NetDevPack.Security.PasswordHasher.sln differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Argon2/Argon2Tests.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Argon2/Argon2Tests.cs
index 8687407..cd88ea8 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/Argon2/Argon2Tests.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/Argon2/Argon2Tests.cs differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Bcrypt/BcryptTests.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Bcrypt/BcryptTests.cs
index afdb8fc..69d7a15 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/Bcrypt/BcryptTests.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/Bcrypt/BcryptTests.cs differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Compatibility/StoredHashCompatibilityTests.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Compatibility/StoredHashCompatibilityTests.cs
new file mode 100644
index 0000000..5267c96
--- /dev/null
+++ b/tests/NetDevPack.Security.PasswordHasher.Tests/Compatibility/StoredHashCompatibilityTests.cs
@@ -0,0 +1,82 @@
+using AwesomeAssertions;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Options;
+using NetDevPack.Security.PasswordHasher.Argon2;
+using NetDevPack.Security.PasswordHasher.Bcrypt;
+using NetDevPack.Security.PasswordHasher.Core;
+using NetDevPack.Security.PasswordHasher.Scrypt;
+using System;
+using Xunit;
+
+namespace NetDevPack.Security.PasswordHasher.Tests.Compatibility;
+
+///
+/// Hashes produced by released versions (7.1.2, net8/net9/net10, Sodium.Core 1.4.0).
+/// They are persisted in users' databases, so every future version must keep verifying them.
+/// Never regenerate these values: a failure here means a breaking change for existing users.
+///
+public class StoredHashCompatibilityTests
+{
+ private const string Password = "NetDevPack@2026!";
+
+ private const string Argon2IdHash = "$argon2id$v=19$m=32768,t=4,p=1$pd5q71+pxdBYWOWr0WHURg$w7UAva7pdfi6K0OhRzqjjcG9EgoJq9eBqVoy45qI3k4";
+ private const string ScryptHash = "$7$C6..../....Sw9xiX8D8fUQICwIxbJ3yURuwUcydVkCdLbInYMKL3A$9B5V6ea2FfSmJYHS9zMorQ1EU0h2IhdlcWjl6tXaXvA";
+ private const string AspNetIdentityV3Hash = "AQAAAAIAAYagAAAAEBEIj9XNFNCMoIgudDswzLWiJMbL4a9My9d16z4d5XQaZU8lyGc06t5hW0fzJLyM0A==";
+ private const string AspNetIdentityV2Hash = "AHtzSDgvdpCQ+2cOnYy4c40mVHtcwX9FubeRRCCfzZy59sxQMCKiRKuk3wuuR7n00g==";
+
+ private static readonly GenericUser User = new();
+
+ private static IPasswordHasher Argon2() => new Argon2Id(new PasswordHasher());
+ private static IPasswordHasher Scrypt() => new Scrypt(new PasswordHasher());
+ private static IPasswordHasher BCrypt() => new BCrypt(new PasswordHasher());
+
+ public static TheoryData Hashers => new() { "argon2", "scrypt", "bcrypt" };
+
+ private static IPasswordHasher Create(string name) => name switch
+ {
+ "argon2" => Argon2(),
+ "scrypt" => Scrypt(),
+ "bcrypt" => BCrypt(),
+ _ => throw new ArgumentOutOfRangeException(nameof(name))
+ };
+
+ [Fact]
+ public void Argon2_ShouldVerifyStoredHash()
+ {
+ Argon2().VerifyHashedPassword(User, Argon2IdHash, Password).Should().Be(PasswordVerificationResult.Success);
+ Argon2().VerifyHashedPassword(User, Argon2IdHash, "wrong-password").Should().Be(PasswordVerificationResult.Failed);
+ }
+
+ [Fact]
+ public void Scrypt_ShouldVerifyStoredHash()
+ {
+ Scrypt().VerifyHashedPassword(User, ScryptHash, Password).Should().Be(PasswordVerificationResult.Success);
+ Scrypt().VerifyHashedPassword(User, ScryptHash, "wrong-password").Should().Be(PasswordVerificationResult.Failed);
+ }
+
+ [Theory]
+ [InlineData("$2a$04$BYD7oqub9f89KabtZo2YlO.VMdveJEfDWbldNmtNkbwI97VjH8p.u")]
+ [InlineData("$2b$04$I.40oldQQT58YawO7WmQVuxLosrUtNhNhqhJU6qRbghpe5fxNdr7a")]
+ [InlineData("$2y$04$.5ZIsWyHemKEx0f.N5GzEO1hKv2TmQa3xlPPoHw6SFiKjRA7ggWOW")]
+ public void BCrypt_ShouldVerifyStoredHash(string hash)
+ {
+ BCrypt().VerifyHashedPassword(User, hash, Password).Should().Be(PasswordVerificationResult.Success);
+ BCrypt().VerifyHashedPassword(User, hash, "wrong-password").Should().Be(PasswordVerificationResult.Failed);
+ }
+
+ [Theory]
+ [MemberData(nameof(Hashers))]
+ public void ShouldAskForRehashWhenStoredHashIsAspNetIdentityV3(string hasher)
+ {
+ Create(hasher).VerifyHashedPassword(User, AspNetIdentityV3Hash, Password).Should().Be(PasswordVerificationResult.SuccessRehashNeeded);
+ Create(hasher).VerifyHashedPassword(User, AspNetIdentityV3Hash, "wrong-password").Should().Be(PasswordVerificationResult.Failed);
+ }
+
+ [Theory]
+ [MemberData(nameof(Hashers))]
+ public void ShouldAskForRehashWhenStoredHashIsAspNetIdentityV2(string hasher)
+ {
+ Create(hasher).VerifyHashedPassword(User, AspNetIdentityV2Hash, Password).Should().Be(PasswordVerificationResult.SuccessRehashNeeded);
+ Create(hasher).VerifyHashedPassword(User, AspNetIdentityV2Hash, "wrong-password").Should().Be(PasswordVerificationResult.Failed);
+ }
+}
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/GenericUserFaker.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/GenericUserFaker.cs
index 0a9a032..21c9928 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/GenericUserFaker.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/GenericUserFaker.cs differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/ImprovedPasswordHasherOptionsFaker.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/ImprovedPasswordHasherOptionsFaker.cs
index b8fa3cb..630b544 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/ImprovedPasswordHasherOptionsFaker.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/Fakers/ImprovedPasswordHasherOptionsFaker.cs differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/GenericUser.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/GenericUser.cs
index f92d283..4bb80aa 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/GenericUser.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/GenericUser.cs differ
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/NetDevPack.Security.PasswordHasher.Tests.csproj b/tests/NetDevPack.Security.PasswordHasher.Tests/NetDevPack.Security.PasswordHasher.Tests.csproj
index 7c5f5db..3df4709 100644
--- a/tests/NetDevPack.Security.PasswordHasher.Tests/NetDevPack.Security.PasswordHasher.Tests.csproj
+++ b/tests/NetDevPack.Security.PasswordHasher.Tests/NetDevPack.Security.PasswordHasher.Tests.csproj
@@ -1,26 +1,21 @@
-
-
+
- net8.0;net9.0;net10.0
+ net10.0
+ Exe
false
+ true
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/tests/NetDevPack.Security.PasswordHasher.Tests/Scrypt/ScryptTests.cs b/tests/NetDevPack.Security.PasswordHasher.Tests/Scrypt/ScryptTests.cs
index 1a52ffb..c387772 100644
Binary files a/tests/NetDevPack.Security.PasswordHasher.Tests/Scrypt/ScryptTests.cs and b/tests/NetDevPack.Security.PasswordHasher.Tests/Scrypt/ScryptTests.cs differ