Hasher
interface Hasher
Defines the contract for hashing and verifying values, typically user passwords. Implementations wrap a specific hashing algorithm (e.g.
bcrypt or Argon2) behind a common interface so that callers hash and verify without depending on the underlying algorithm. This keeps the choice of algorithm and its parameters in a single place and allows it to be changed or upgraded without altering calling code.
Methods
Hashes the given plain-text value.
Determines whether a previously computed hash should be re-created, for example because the algorithm's configured cost or parameters have since changed. Typically checked after a successful verify() so an out-of-date hash can be transparently upgraded.
Verifies that a plain-text value matches a previously computed hash.
Details
at line 20
string
make(string $value)
Hashes the given plain-text value.
at line 32
bool
needsRehash(string $hashed)
Determines whether a previously computed hash should be re-created, for example because the algorithm's configured cost or parameters have since changed. Typically checked after a successful verify() so an out-of-date hash can be transparently upgraded.
at line 41
bool
verify(string $value, string $hashed)
Verifies that a plain-text value matches a previously computed hash.