Constants

ALGORITHM_MAXIMUM_OUTPUT

ALGORITHM_MAXIMUM_OUTPUT

The internal maximum length in bytes of the raw output digest for the algorithm.

ALGORITHM_NAME

ALGORITHM_NAME

The internal name of the algorithm.

VERSION_I

VERSION_I

The Argon2i variation setting constant.

VERSION_ID

VERSION_ID

The Argon2id variation setting constant.

Properties

$digestFormat

$digestFormat : integer

The digest output format property storage.

Type

integer — The output format integer code value.

$useNative

$useNative : boolean

Flag to force native code polyfill realizations, if available.

Type

boolean — Flag to force native realizations.

$salt

$salt : string

The salt string property storage.

Type

string — The salting string value.

$saltingMode

$saltingMode : integer

The salting mode property storage.

Type

integer — The salting mode integer code value.

$inFrontCases

$inFrontCases : array

List of salting modes that add the salt at the front side of the input data.

Type

array — Salting mode codes.

$inBackCases

$inBackCases : array

List of salting modes that add the salt at the back side of the input data.

Type

array — Salting mode codes.

$inSpecialCases

$inSpecialCases : array

List of salting modes that use complex salt and input data manipulation procedures.

Type

array — Salting mode codes.

$algorithmVariation

$algorithmVariation : integer

The internal algorithm variation property storage.

Type

integer — The algorithm variation value.

$memoryCost

$memoryCost : integer

The digestion internal computational memory cost property storage.

Type

integer — The algorithmic memory cost value.

$timeCost

$timeCost : integer

The digestion internal computational time cost property storage.

Type

integer — The algorithmic time cost value.

$threadsCost

$threadsCost : integer

The digestion internal computational thread cost property storage.

Type

integer — The algorithmic thread cost value.

Methods

setMemoryCost()

setMemoryCost(integer  $cost) : $this

Setter for the memory cost property.

Parameters

integer $cost

The algorithmic memory cost.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getMemoryCost()

getMemoryCost() : integer

Getter for the memory cost property.

Returns

integer —

The algorithmic memory cost.

setTimeCost()

setTimeCost(integer  $cost) : $this

Setter for the time cost property.

Parameters

integer $cost

The algorithmic time cost.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getTimeCost()

getTimeCost() : integer

Getter for the time cost property.

Returns

integer —

The algorithmic time cost.

setThreadsCost()

setThreadsCost(integer  $cost) : $this

Setter for the threads cost property.

Parameters

integer $cost

The algorithmic threads cost.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getThreadsCost()

getThreadsCost() : integer

Getter for the threads cost property.

Returns

integer —

The algorithmic threads cost.

setAlgorithmVariation()

setAlgorithmVariation(integer  $version) : $this

Setter for the algorithm variation version property.

Parameters

integer $version

The algorithm variation version.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getAlgorithmVariation()

getAlgorithmVariation() : integer

Getter for the algorithm variation version property.

Returns

integer —

The algorithm variation version.

__construct()

__construct() 

Password-based key derivation algorithm constructor.

__debugInfo()

__debugInfo() : array

Get debug information for the class instance.

Returns

array —

Debug information.

hashData()

hashData(string  $data) : string

Calculates a hash value for the given data.

Parameters

string $data

The input string.

Throws

\Exception

Validation errors.

Returns

string —

The digest.

verifyHash()

verifyHash(string  $data, string  $digest) : boolean

Securely compares and verifies if a digestion value is for the given input data.

Parameters

string $data

The input string.

string $digest

The digest string.

Throws

\Exception

Validation errors.

Returns

boolean —

The result of the secure comparison.

setSalt()

setSalt(string  $salt) : $this

Setter for the salt string property.

Parameters

string $salt

The salt string.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getSalt()

getSalt() : string

Getter for the salt string property.

Returns

string —

The salt string.

setSaltingMode()

setSaltingMode(integer  $saltingMode) : $this

Setter for the salting mode code property.

Parameters

integer $saltingMode

The salting mode code.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getSaltingMode()

getSaltingMode() : integer

Getter for the salt mode code property.

Returns

integer —

The salt mode code.

setDigestFormat()

setDigestFormat(integer  $digestFormat) : $this

Setter for the digest format code property.

Parameters

integer $digestFormat

The digest format code.

Throws

\Exception

Validation errors.

Returns

$this —

The hash algorithm object.

getDigestFormat()

getDigestFormat() : integer

Getter for the digest format code property.

Returns

integer —

The digest format code.

validateVersion()

validateVersion(integer  $version) 

Internal method for version range validation.

Parameters

integer $version

The version for validation checks.

Throws

\Exception

Validation errors.

changeOutputFormat()

changeOutputFormat(string  $digest) : string

Internal method for converting the digest's output format representation via the chosen format.

Parameters

string $digest

The output digest.

Returns

string —

The input data with proper salting.

convertFormattedDigest()

convertFormattedDigest(string  $digest) : string

Internal method for converting a formatted digest to raw bytes.

Parameters

string $digest

The digest string.

Returns

string —

The raw bytes digest representation.

fetchAlgorithmVariation()

fetchAlgorithmVariation() : integer|string

Fetch the correctly formatted internal variation for digestion.

Returns

integer|string —

The chosen variation for password hashing.

fetchAlgorithmParameters()

fetchAlgorithmParameters() : array

Fetch the correctly formatted internal parameters for digestion.

Returns

array —

The chosen parameters for password hashing.

saltAtFront()

saltAtFront(string  $data) 

Internal method for grouping salting modes that add to the front of the input data.

Parameters

string $data

The input data for hashing.

saltAtBack()

saltAtBack(string  $data) 

Internal method for grouping salting modes that add to the back of the input data.

Parameters

string $data

The input data for hashing.

saltAtSpecial()

saltAtSpecial(string  $data) 

Internal method for grouping salting modes that use complex manipulations of the salt and input data.

Parameters

string $data

The input data for hashing.

addSaltString()

addSaltString(string  $data) : string

Internal method for adding the salt string to the input data via the chosen salting mode.

Parameters

string $data

The input data for hashing.

Returns

string —

The input data with proper salting.