Skip to content

devtoolboxuk/hashing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hashing

Hashing Service

Build Status Coveralls CodeCov

Table of Contents

Background

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

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();
Set Hashing Key
$this->hashingService->setHashingKey($key);
Get Hashing key
$this->hashingKey = $this->hashingService->getHashingKey();
Hashing Data

Pass in the data to be hashed.

$this->hashingService->hash("Test Data");
Get Hashed Data

Returns the hash of the data.

$this->hashingService->getHashedData()

By default, the Hashing service uses the SHA256 Algoritm, and the HMAC Hashing Function

Retrieve Hashed Data
$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'

Set Algorithm
$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...)

Set Hashing Function
$this->hashingService->setHashFunction('hmac');

Maintainers

@DevToolboxUk.

License

MIT © DevToolboxUK