Aplus Framework Docs

GenericHash
in package

Class GenericHash.

Table of Contents

$hashLength  : int
$key  : string
__construct()  : mixed
GenericHash constructor.
makeKey()  : string
Makes a key.
signature()  : string
Gets a message signature.
verify()  : bool
Verifies if a message matches a signature.
makeHash()  : string
Makes a hash to a message.
validateHashLength()  : void
Validates a hash length.
validateKey()  : void
Validates a key.

Properties

$hashLength

protected int $hashLength = \SODIUM_CRYPTO_GENERICHASH_BYTES

Methods

__construct()

GenericHash constructor.

public __construct(string $key[, int $hashLength = SODIUM_CRYPTO_GENERICHASH_BYTES ]) : mixed
Parameters
$key : string
$hashLength : int = SODIUM_CRYPTO_GENERICHASH_BYTES
Tags
see
GenericHash::makeKey()
throws
LengthException

if key length is not between 16 and 64

throws
RangeException

if the hashLength value is not in the range 16 to 64

Return values
mixed

makeKey()

Makes a key.

public static makeKey() : string
Return values
string

signature()

Gets a message signature.

public signature(string $message[, int|null $hashLength = null ]) : string
Parameters
$message : string
$hashLength : int|null = null

A custom hash length or null to use the length set in the constructor

Tags
throws
RangeException

if the hashLength is set and is not in the range 16 to 64

throws
SodiumException
Return values
string

verify()

Verifies if a message matches a signature.

public verify(string $message, string $signature[, int|null $hashLength = null ]) : bool
Parameters
$message : string
$signature : string
$hashLength : int|null = null

A custom hash length or null to use the length set in the constructor

Tags
throws
RangeException

if the hashLength is set and is not in the range 16 to 64

throws
SodiumException
Return values
bool

makeHash()

Makes a hash to a message.

protected makeHash(string $message[, int|null $length = null ]) : string
Parameters
$message : string
$length : int|null = null

A custom length or null to use the length set in the constructor

Tags
throws
RangeException

if the length is set and is not in the range 16 to 64

throws
SodiumException
Return values
string

validateHashLength()

Validates a hash length.

protected validateHashLength(int $length) : void
Parameters
$length : int
Tags
throws
RangeException

if the length value is not in the range 16 to 64

Return values
void

validateKey()

Validates a key.

protected validateKey(string $key) : void
Parameters
$key : string
Tags
throws
LengthException

if key length is not between 16 and 64

Return values
void

Search results