GenericHash class
Framework\Crypto\GenericHash
Class GenericHash.
Defined in libraries/crypto/src/GenericHash.php
Properties #
- $key
- -
- $hashLength
- -
$key
protected string $key
$hashLength
protected int $hashLength = 32
Methods #
- __construct()
- GenericHash constructor.
- makeKey()
- Makes a key.
- signature()
- Gets a message signature.
- verify()
- Verifies if a message matches a signature.
- makeHash()
- Makes a hash to a message.
- validateHashLength()
- Validates a hash length.
- validateKey()
- Validates a key.
__construct()
public function __construct(string $key, int $hashLength = 32)
GenericHash constructor.
Parameters
- string $key
- int $hashLength
makeKey()
public static function makeKey(): string
Makes a key.
Returns
string
signature()
public function signature(string $message, ?int $hashLength = NULL): string
Gets a message signature.
Parameters
- string $message
- ?int $hashLength - A custom hash length or null to use the length set in the constructor
Returns
string
verify()
public function verify(string $message, string $signature, ?int $hashLength = NULL): bool
Verifies if a message matches a signature.
Parameters
- string $message
- string $signature
- ?int $hashLength - A custom hash length or null to use the length set in the constructor
Returns
bool
makeHash()
protected function makeHash(string $message, ?int $length = NULL): string
Makes a hash to a message.
Parameters
- string $message
- ?int $length - A custom length or null to use the length set in the constructor
Returns
string
validateHashLength()
protected function validateHashLength(int $length): void
Validates a hash length.
Parameters
- int $length
Returns
void
validateKey()
protected function validateKey(string $key): void
Validates a key.
Parameters
- string $key
Returns
void