LegacyPasswordHasher
in package
Verifies passwords hashed with the old algorithm: `crypt($password, '$2a$07$' . $salt)`.
PHP's password_verify() supports $2a$ (bcrypt variant), so no special fallback is needed.
The class documents the migration procedure explicitly.
Table of Contents
Properties
Methods
- __construct() : mixed
- needsRehash() : bool
- Returns true when the hash comes from the old algorithm and should be rehashed.
- rehash() : string
- Returns a new hash for the migration.
- verify() : bool
- Verifies the password; works for new and old (`$2a$`) hashes.
Properties
$passwordHasher read-only
private
PasswordHasher
$passwordHasher
Methods
__construct()
public
__construct(PasswordHasher $passwordHasher) : mixed
Parameters
- $passwordHasher : PasswordHasher
needsRehash()
Returns true when the hash comes from the old algorithm and should be rehashed.
public
needsRehash(string $hash) : bool
Parameters
- $hash : string
Return values
boolrehash()
Returns a new hash for the migration.
public
rehash(string $password) : string
Parameters
- $password : string
Return values
stringverify()
Verifies the password; works for new and old (`$2a$`) hashes.
public
verify(string $password, string $hash) : bool
Parameters
- $password : string
- $hash : string