Hashing Service
Although there are many hashing services out there, I decided to create a basic one for use on some of my projects.
The Unit Tests have been run on PHP 5.4 and 7.2. This is to help support legacy projects.
Usage of the hashing service
$ composer require devtoolboxuk/Hashing
Then include Composer's generated vendor/autoload.php to enable autoloading:
require 'vendor/autoload.php';
use devtoolboxuk/Hashing;
$this->hashingService = new HashingService();
$this->hashingService->setHashingKey($key);
$this->hashingKey = $this->hashingService->getHashingKey();
Pass in the data to be hashed.
$this->hashingService->hash("Test Data");
Returns the hash of the data.
$this->hashingService->getHashedData()
By default, the Hashing service uses the SHA256 Algoritm, and the HMAC Hashing Function
$this->hashingService->setHashingKey($key);
$this->hashingKey = $this->hashingService->getHashingKey();
The algorithm for hashing can be changed using this function, currently only the following algorithms are supported; 'sha256', 'sha384', 'sha512', 'md5'
$this->hashingService->setHashingKey($key);
$this->hashingKey = $this->hashingService->getHashingKey();
The hashing function can also be changed to use either hmac or not (others may come along...)
$this->hashingService->setHashFunction('hmac');
MIT © DevToolboxUK