PHPackages                             edwinmugendi/hashdigest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. edwinmugendi/hashdigest

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

edwinmugendi/hashdigest
=======================

Hash Generator and Verifier

1(12y ago)16061PHPPHP &gt;=5.1.2

Since Feb 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/edwinmugendi/hashdigest)[ Packagist](https://packagist.org/packages/edwinmugendi/hashdigest)[ RSS](/packages/edwinmugendi-hashdigest/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

hashdigest
==========

[](#hashdigest)

A PHP Hash Generator and Verifier

This is a wrapper on the PHP function HASH for generating hash digests using sha256 algorithm and also verifying a given hash againist given data.

Installation
============

[](#installation)

### Requirements

[](#requirements)

PHP v&gt;=5.1.2+ ### With Composer

[](#with-composer)

The easiest way to install Carbon is via composer. Create the following `composer.json` file and run the php composer.phar install command to install it. ```json "require": { "edwinmugendi/hashdigest": "master" } ``` ### Without Composer

[](#without-composer)

Why not use [composer](http://getcomposer.org/)? Anyway, Download [Digester.php](https://github.com/edwinmugendi/hashdigest/blob/master/src/HashDigest/Digester.php) from the repo and save the file somewhere in your project.

```php use HashDigest\\Digester;$dataToHash = array( 'name'=&gt;'Ali', 'age'=&gt;'12', 'city'=&gt;'Nairobi', 'work'=&gt;'Software Engineer', 'at'=&gt;'Sapama.com' );

$hash = Digester::digest($dataToHash);

echo 'Generated Hash is '; echo "\\n"; echo $hash; echo "\\n"; $isValid = Digester::isHashValid($hash, $dataToHash);

echo "Hash is ". ($isValid ? 'valid': 'not valid');

```
Algorithm
Hash generation
The hash is generated by:

1. The ```digest($dataToHash, $algo = 'sha256', $raw_output = false, $separator = '.')``` function takes a string or array as parameter of data to be hashed eg;

```php
