class Hash (View source)

Constants

PADDING_SHA3

Padding Types

PADDING_SHAKE

Padding Types

Methods

__construct(string $hash = 'sha256')

Default Constructor.

setKey(string $key = false)

Sets the key for HMACs

setNonce(string $nonce = false)

Sets the nonce for UMACs

string
getHash()

Gets the hash function.

setHash(string $hash)

Sets the hash function.

string
hash(string $text)

Compute the Hash / HMAC / UMAC.

int
getLength()

Returns the hash length (in bits)

int
getLengthInBytes()

Returns the hash length (in bytes)

int
getBlockLength()

Returns the block length (in bits)

int
getBlockLengthInBytes()

Returns the block length (in bytes)

__toString()

__toString() magic method

Details

__construct(string $hash = 'sha256')

Default Constructor.

Parameters

string $hash

setKey(string $key = false)

Sets the key for HMACs

Keys can be of any length.

Parameters

string $key

setNonce(string $nonce = false)

Sets the nonce for UMACs

Keys can be of any length.

Parameters

string $nonce

string getHash()

Gets the hash function.

As set by the constructor or by the setHash() method.

Return Value

string

setHash(string $hash)

Sets the hash function.

Parameters

string $hash

string hash(string $text)

Compute the Hash / HMAC / UMAC.

Parameters

string $text

Return Value

string

int getLength()

Returns the hash length (in bits)

Return Value

int

int getLengthInBytes()

Returns the hash length (in bytes)

Return Value

int

int getBlockLength()

Returns the block length (in bits)

Return Value

int

int getBlockLengthInBytes()

Returns the block length (in bytes)

Return Value

int

__toString()

__toString() magic method