class BcryptHasher extends AbstractHasher implements Hasher

Properties

protected int $rounds

The default cost factor.

protected bool $verifyAlgorithm

Indicates whether to perform an algorithm check.

protected int|null $limit

The maximum allowed length of strings that can be hashed.

Methods

array
info(string $hashedValue)

Get information about the given hashed value.

bool
check(string $value, string|null $hashedValue, array $options = [])

Check the given plain value against a hash.

bool
hasHash(string|null $hashedValue)

Determine whether a hash value is present.

__construct(array $options = [])

Create a new hasher instance.

string
make(string $value, array $options = [])

Hash the given value.

bool
needsRehash(string|null $hashedValue, array $options = [])

Check if the given hash has been hashed using the given options.

bool
verifyConfiguration(string $hashedValue)

Verifies that the configuration is less than or equal to what is configured.

bool
isUsingCorrectAlgorithm(string $hashedValue)

Verify the hashed value's algorithm.

bool
isUsingValidOptions(string $hashedValue)

Verify the hashed value's options.

setRounds(int $rounds)

Set the default password work factor.

int
cost(array $options = [])

Extract the cost value from the options array.

Details

in AbstractHasher at line 14
array info(string $hashedValue)

Get information about the given hashed value.

Parameters

string $hashedValue

Return Value

array

at line 71
bool check(string $value, string|null $hashedValue, array $options = [])

Check the given plain value against a hash.

Parameters

string $value
string|null $hashedValue
array $options

Return Value

bool

Exceptions

RuntimeException

in AbstractHasher at line 34
protected bool hasHash(string|null $hashedValue)

Determine whether a hash value is present.

Parameters

string|null $hashedValue

Return Value

bool

at line 33
__construct(array $options = [])

Create a new hasher instance.

Parameters

array $options

at line 49
string make(string $value, array $options = [])

Hash the given value.

Parameters

string $value
array $options

Return Value

string

Exceptions

RuntimeException
InvalidArgumentException

at line 87
bool needsRehash(string|null $hashedValue, array $options = [])

Check if the given hash has been hashed using the given options.

Parameters

string|null $hashedValue
array $options

Return Value

bool

at line 103
bool verifyConfiguration(string $hashedValue)

internal  
 

Verifies that the configuration is less than or equal to what is configured.

Parameters

string $hashedValue

Return Value

bool

at line 111
protected bool isUsingCorrectAlgorithm(string $hashedValue)

Verify the hashed value's algorithm.

Parameters

string $hashedValue

Return Value

bool

at line 119
protected bool isUsingValidOptions(string $hashedValue)

Verify the hashed value's options.

Parameters

string $hashedValue

Return Value

bool

at line 142
BcryptHasher setRounds(int $rounds)

Set the default password work factor.

Boot-only. Mutates the shared hasher instance held by the HashManager; per-request use races across coroutines.

Parameters

int $rounds

Return Value

BcryptHasher

at line 152
protected int cost(array $options = [])

Extract the cost value from the options array.

Parameters

array $options

Return Value

int