Password class
Password utilities using bcrypt for secure password hashing
Bcrypt is a password hashing function designed to be slow and computationally expensive, making it resistant to brute-force attacks. It automatically handles salting and uses adaptive hashing to stay secure over time.
Constructors
- Password()
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
-
generate(
{int length = 16, bool includeSymbols = true}) → String - Generate a random secure password
-
hash(
String password, {int cost = defaultCost}) → String -
Hash a password using bcrypt
override
-
needsRehash(
String hashedPassword, {int targetCost = defaultCost}) → bool - Check if a hash needs to be rehashed (cost factor changed)
-
verify(
String password, String hashedPassword) → bool - Verify a password against a bcrypt hash
Constants
- defaultCost → const int
- Default cost factor for bcrypt (10 = 2^10 = 1024 iterations) Higher values increase security but also computation time Recommended: 10-12 for production