Hasher class base
Secure password hashing utility using PBKDF2-SHA256.
Features:
- 100,000 iterations (configurable via
_iterations) - 16-byte cryptographically secure salt
- 256-bit derived key
- Constant-time verification
- Standard hash format:
$pbkdf2-sha256$iterations$salt$hash
Security:
- Uses
Random.secure()for salt generation - HMAC-SHA256 with proper key padding
- Constant-time string comparison
Example:
final hash = Hasher.hashPassword('mySecret123');
final isValid = Hasher.verifyPassword('mySecret123', hash); // true
Constructors
- Hasher()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
hashPassword(
String password) → String - Hashes a password securely.
-
verifyPassword(
String password, String? storedHash) → bool - Verifies a password against a stored hash.