CoolCMS API

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

$passwordHasher  : PasswordHasher

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

Methods

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
bool

rehash()

Returns a new hash for the migration.

public rehash(string $password) : string
Parameters
$password : string
Return values
string

verify()

Verifies the password; works for new and old (`$2a$`) hashes.

public verify(string $password, string $hash) : bool
Parameters
$password : string
$hash : string
Return values
bool
On this page

Search results