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
TUserThe Identity user type.
- Inheritance
-
objectArgon2idPasswordHasher<TUser>
- Implements
-
IPasswordHasher<TUser>
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
hasherArgon2idPasswordHasherThe shared, thread-safe core hasher (typically a singleton).
Exceptions
- ArgumentNullException
hasheris 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
userTUserThe user whose password is to be hashed.
passwordstringThe password to hash.
Returns
- string
A hashed representation of the supplied
passwordfor the specifieduser.
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
userTUserThe user whose password should be verified.
hashedPasswordstringThe hash value for a user's stored password.
providedPasswordstringThe 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.