\Gishiki\Security\HashingHasher

This class provides hashing functions while abstracting the algorithm.

Note: This class uses OpenSSL for strong encryption

Summary

Methods
Properties
Constants
__construct()
hash()
verify()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$algorithm
$algorithmRequired
$hashCallback
$verifyCallback
N/A

Properties

$algorithm

$algorithm : integer|null

Type

integer|null — the hashing algorithm, or null on error

$algorithmRequired

$algorithmRequired : boolean

Type

boolean — true if the algorithm name has to be passed

$hashCallback

$hashCallback : string

Type

string — the name of the function to be called to produce a message digest

$verifyCallback

$verifyCallback : string

Type

string — the name of the function to be called to verify a message digest

Methods

__construct()

__construct(string  $algorithm = \Gishiki\Security\Hashing\Algorithm::BCRYPT) 

Create an object that provides an easy and unique interface to use any of the supported algorithms

Parameters

string $algorithm

the algorithm to be used

Throws

\Gishiki\Security\Hashing\HashingException

the given algorithm is unsupported

hash()

hash(string  $message) : string

Generate the hash of the given message using the chosen algorithm

Parameters

string $message

the message to be hashed

Throws

\InvalidArgumentException

the message or the message digest is given as a non-string or an empty string

\Gishiki\Security\Hashing\HashingException

the error occurred while generating the hash for the given message

Returns

string —

the result of the hashing algorithm

verify()

verify(string  $message, string  $digest) : boolean

Check the hash of the given message using the chosen algorithm

Parameters

string $message

the message to be checked against the digest

string $digest

the message digest to be checked

Throws

\InvalidArgumentException

the message or the message digest is given as a non-string or an empty string

\Gishiki\Security\Hashing\HashingException

the error occurred while generating the hash for the given message

Returns

boolean —

the result of the check: true on success, false otherwise