Constants

KECCAK_ROUNDS

KECCAK_ROUNDS

Internal algorithm rounds count.

KECCAK_SUFIX

KECCAK_SUFIX

Internal algorithm suffix byte.

Properties

$isX64

$isX64 : null|boolean

Internal flag marking if the PHP version is x64 based.

Note: null => auto-check on next call, true => x64, false => x32.

Type

null|boolean — Is it a x64 system.

$mbString

$mbString : null|boolean

Internal flag to enable or disable the `mbstring` extension usage.

Note: null => auto-check on next call, true => available, false => not available.

Type

null|boolean — Is the `mbstring` extension supported.

$fKeccakRotc

$fKeccakRotc : array

Internal algorithm hardcoded data.

Type

array — Internal data for manipulations.

$fKeccakPiln

$fKeccakPiln : array

Internal algorithm hardcoded data.

Type

array — Internal data for manipulations.

Methods

getInstance()

getInstance() : static|null

Gives a unified access point for the current object instance.

Returns

static|null —

An instance.

__wakeup()

__wakeup() 

Lock the reinitialization and unserialization abilities of the class.

__sleep()

__sleep() 

Lock the serialization abilities of the class.

__toString()

__toString() : string

Return the name of the current defined class that extends the class.

Returns

string —

Name of the class.

resetSystemChecks()

resetSystemChecks() 

Global method for resetting internal system check.

digest224()

digest224(string|mixed  $inputData, boolean|integer|null  $rawOutput = false) : string

The SHA-3-224 hashing function.

Parameters

string|mixed $inputData

The input message to be hashed.

boolean|integer|null $rawOutput

When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.

Throws

\Exception

Validation errors.

Returns

string —

The output digest.

digest256()

digest256(string|mixed  $inputData, boolean|integer|null  $rawOutput = false) : string

The SHA-3-256 hashing function.

Parameters

string|mixed $inputData

The input message to be hashed.

boolean|integer|null $rawOutput

When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.

Throws

\Exception

Validation errors.

Returns

string —

The output digest.

digest384()

digest384(string|mixed  $inputData, boolean|integer|null  $rawOutput = false) : string

The SHA-3-384 hashing function.

Parameters

string|mixed $inputData

The input message to be hashed.

boolean|integer|null $rawOutput

When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.

Throws

\Exception

Validation errors.

Returns

string —

The output digest.

digest512()

digest512(string|mixed  $inputData, boolean|integer|null  $rawOutput = false) : string

The SHA-3-512 hashing function.

Parameters

string|mixed $inputData

The input message to be hashed.

boolean|integer|null $rawOutput

When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.

Throws

\Exception

Validation errors.

Returns

string —

The output digest.

__construct()

__construct() 

Locks the creation of new objects but allows static creation and extending.

getRndcArray()

getRndcArray() : array

Get different hardcoded data for internal manipulations depending on the system word size.

Returns

array —

Internal data for manipulations.

fKeccakAlgorithm()

fKeccakAlgorithm(array  $state, integer  $rounds) 

Internal data manipulation for the Keccak algorithm.

Parameters

array $state

The state matrix.

integer $rounds

The rounds count.

keccakAlgorithm()

keccakAlgorithm(string|mixed  $inputBytes, integer  $outputLength, integer  $algorithmSuffix, boolean|integer|null  $rawOutput) : string

The internal Keccak native implementation.

Parameters

string|mixed $inputBytes

The data for hashing.

integer $outputLength

The output length for the algorithm.

integer $algorithmSuffix

The used integer suffix for the algorithm.

boolean|integer|null $rawOutput

Flag for using raw byte output instead of HEX.

Returns

string —

The output digest.

binarySafeStrLength()

binarySafeStrLength(string  $string) : integer

Get the string's length in 8-bit representation of raw bytes.

Parameters

string $string

The string for length measuring.

Returns

integer —

The string's length.

binarySafeSubStr()

binarySafeSubStr(string  $string, integer  $start, integer|null  $length = null) : boolean|string

Return a part of a string in length via the 8-bit representation of raw bytes.

Parameters

string $string

The input string

integer $start

The starting position.

integer|null $length

The length to take.

Returns

boolean|string —

The extracted part of string or false on failure.

calculateDigest()

calculateDigest(string|mixed  $inputData, integer  $outputLength, boolean|integer|null  $rawOutput = false) : boolean|string

Internal static method for single point consumption of the Keccak implementation.

Parameters

string|mixed $inputData

The data for hashing.

integer $outputLength

The output length for the algorithm.

boolean|integer|null $rawOutput

Flag for using raw byte output instead of HEX.

Throws

\Exception

Validation errors.

Returns

boolean|string —

The output digest for the given input parameters.

__clone()

__clone() 

Lock the ability to clone properties and create a new dynamic instance of the class.