HTPasswd
Less than 1 minute
HTPasswd
Password hasher for Apache .htpasswd files.
class HTPasswd implements \Hazaar\Auth\Interface\PasswordHasherImplements: Hazaar\Auth\Interface\PasswordHasher
Verifies the formats htpasswd writes:
$2y$(bcrypt)$apr1$(APR1-MD5){SHA}(SHA-1)
New hashes are bcrypt, the only password_hash() algorithm the htpasswd format supports. With the digest method they are APR1-MD5 instead, and nothing is ever rehashed.
Constants
string
private const string = nullstring
private const string = nullProperties
method
password (bcrypt, the default) or digest (APR1-MD5)
private string $method = 'password'Type: string
Methods
__construct
public __construct(string $method = 'password'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$method | string | password (bcrypt, the default) or digest (APR1-MD5) |
hash
public hash(string $password, string $identity): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$password | string | |
$identity | string |
verify
public verify(string $password, string $stored, string $identity): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$password | string | |
$stored | string | |
$identity | string |
needsRehash
public needsRehash(string $stored): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$stored | string |
apr1
Computes an APR1-MD5 hash ($apr1$<salt>$<hash>), as made by htpasswd -m.
public apr1(string $password, string $salt): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$password | string | |
$salt | string |
Generated by Hazaar API Doc Generator on Wed, 28 Oct 2026 08:43:30 +0000