PasswordHasher
Less than 1 minute
PasswordHasher
Hashes passwords for storage and checks them against stored hashes.
interface PasswordHasherA hasher holds no per-user state: everything it needs about the user, including the identity for formats that mix it into the hash, is passed in on each call. This means one hasher can be shared across requests and users.
Methods
hash
Hashes a password for storage.
public hash(string $password, string $identity): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$password | string | |
$identity | string |
verify
Checks a password against a stored hash.
public verify(string $password, string $stored, string $identity): boolReturns: bool
An empty stored hash never matches.
Parameters
| Parameter | Type | Description |
|---|---|---|
$password | string | |
$stored | string | |
$identity | string |
needsRehash
Whether a stored hash should be replaced with a fresh Hazaar\Auth\Interface\PasswordHasher::hash after a successful Hazaar\Auth\Interface\PasswordHasher::verify.
public needsRehash(string $stored): boolReturns: bool
True for legacy formats and for hashes made with outdated algorithm options.
Parameters
| Parameter | Type | Description |
|---|---|---|
$stored | string |
Generated by Hazaar API Doc Generator on Wed, 28 Oct 2026 08:43:30 +0000