Interface IPasswordHasher
- Namespace
- Builvero.Application.Interfaces.Services
- Assembly
- Builvero.Application.dll
Defines the contract for password hashing and verification operations.
public interface IPasswordHasher
Remarks
This interface provides methods for securely hashing passwords before storage and verifying passwords against stored hashes. The implementation uses BCrypt with a work factor of 12.
Methods
HashPassword(string)
Hashes a password using a secure one-way hashing algorithm.
string HashPassword(string password)
Parameters
passwordstringThe plain text password to hash.
Returns
- string
A hashed password string that can be safely stored in the database.
Remarks
The hash is deterministic for the same input but cannot be reversed to obtain the original password. The implementation uses BCrypt with a work factor of 12, which provides a good balance between security and performance.
VerifyPassword(string, string)
Verifies a password against a stored hash.
bool VerifyPassword(string password, string hash)
Parameters
passwordstringThe plain text password to verify.
hashstringThe stored password hash to verify against.
Returns
- bool
trueif the password matches the hash; otherwise,false.
Remarks
This method performs a secure comparison that is resistant to timing attacks.