Table of Contents

Class Argon2idPasswordHasher<TUser>

Namespace
Argon2id.PasswordHasher.AspNetCore
Assembly
Argon2id.PasswordHasher.AspNetCore.dll

An IPasswordHasher<TUser> implementation backed by the secure-by-default Argon2id Argon2idPasswordHasher, suitable for ASP.NET Core Identity.

public sealed class Argon2idPasswordHasher<TUser> : IPasswordHasher<TUser> where TUser : class

Type Parameters

TUser

The Identity user type.

Inheritance
object
Argon2idPasswordHasher<TUser>
Implements

Remarks

Verification reports SuccessRehashNeeded when the stored hash was produced with weaker parameters (or a non-active pepper) than the current configuration, so ASP.NET Core Identity transparently upgrades it on the next sign-in.

Constructors

Argon2idPasswordHasher(Argon2idPasswordHasher)

Creates the adapter around a configured core hasher.

public Argon2idPasswordHasher(Argon2idPasswordHasher hasher)

Parameters

hasher Argon2idPasswordHasher

The shared, thread-safe core hasher (typically a singleton).

Exceptions

ArgumentNullException

hasher is null.

Methods

HashPassword(TUser, string)

Returns a hashed representation of the supplied password for the specified user.

public string HashPassword(TUser user, string password)

Parameters

user TUser

The user whose password is to be hashed.

password string

The password to hash.

Returns

string

A hashed representation of the supplied password for the specified user.

VerifyHashedPassword(TUser, string, string)

Returns a PasswordVerificationResult indicating the result of a password hash comparison.

public PasswordVerificationResult VerifyHashedPassword(TUser user, string hashedPassword, string providedPassword)

Parameters

user TUser

The user whose password should be verified.

hashedPassword string

The hash value for a user's stored password.

providedPassword string

The password supplied for comparison.

Returns

PasswordVerificationResult

A PasswordVerificationResult indicating the result of a password hash comparison.

Remarks

Implementations of this method should be time consistent.