Neuron-PHP

PasswordHasher
in package

Password hashing and validation utility.

Uses PHP's native password_hash() with Argon2id algorithm for secure password storage and verification.

Table of Contents

Properties

$_minLength  : int
$_requireLowercase  : bool
$_requireNumbers  : bool
$_requireSpecialChars  : bool
$_requireUppercase  : bool

Methods

configure()  : self
Configure password requirements from settings
getValidationErrors()  : array<int, string>
Get password validation error messages
hash()  : string
Hash a password using Argon2id or Bcrypt
meetsRequirements()  : bool
Check if password meets strength requirements
needsRehash()  : bool
Check if a hash needs to be rehashed (algorithm upgrade)
setMinLength()  : self
Set minimum password length
setRequireLowercase()  : self
Set whether lowercase letters are required
setRequireNumbers()  : self
Set whether numbers are required
setRequireSpecialChars()  : self
Set whether special characters are required
setRequireUppercase()  : self
Set whether uppercase letters are required
verify()  : bool
Verify a password against a hash

Properties

$_requireSpecialChars

private bool $_requireSpecialChars = false

Methods

configure()

Configure password requirements from settings

public configure(array<string, mixed> $settings) : self
Parameters
$settings : array<string, mixed>
Return values
self

getValidationErrors()

Get password validation error messages

public getValidationErrors(string $password) : array<int, string>
Parameters
$password : string
Return values
array<int, string>

hash()

Hash a password using Argon2id or Bcrypt

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

meetsRequirements()

Check if password meets strength requirements

public meetsRequirements(string $password) : bool
Parameters
$password : string
Return values
bool

needsRehash()

Check if a hash needs to be rehashed (algorithm upgrade)

public needsRehash(string $hash) : bool
Parameters
$hash : string
Return values
bool

setMinLength()

Set minimum password length

public setMinLength(int $minLength) : self
Parameters
$minLength : int
Return values
self

setRequireLowercase()

Set whether lowercase letters are required

public setRequireLowercase(bool $requireLowercase) : self
Parameters
$requireLowercase : bool
Return values
self

setRequireNumbers()

Set whether numbers are required

public setRequireNumbers(bool $requireNumbers) : self
Parameters
$requireNumbers : bool
Return values
self

setRequireSpecialChars()

Set whether special characters are required

public setRequireSpecialChars(bool $requireSpecialChars) : self
Parameters
$requireSpecialChars : bool
Return values
self

setRequireUppercase()

Set whether uppercase letters are required

public setRequireUppercase(bool $requireUppercase) : self
Parameters
$requireUppercase : bool
Return values
self

verify()

Verify a password against a hash

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

        
On this page

Search results