PHPackages                             devhelp/hash - 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. devhelp/hash

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

devhelp/hash
============

Introduces HashGenerator class that can be used to register and use different hash algorithms

1.0(11y ago)0471MITPHPPHP &gt;=5.3

Since Sep 25Pushed 11y ago3 watchersCompare

[ Source](https://github.com/devhelp/hash)[ Packagist](https://packagist.org/packages/devhelp/hash)[ Docs](http://devhelp.pl)[ RSS](/packages/devhelp-hash/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (2)Used By (1)

[![Build Status](https://camo.githubusercontent.com/3c397248f87a48f80b576ab9c935eb08742a43659edfef20f248ff50108c94d5/68747470733a2f2f7472617669732d63692e6f72672f64657668656c702f686173682e706e67)](https://travis-ci.org/devhelp/hash) [![SensioLabsInsight](https://camo.githubusercontent.com/a8444933f1df93985b2befbe73320dcf908d56dadf2a3c0c496da021605802a5/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61376461366238632d393935662d346632322d393463352d3132313263373336373662392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/a7da6b8c-995f-4f22-94c5-1212c73676b9)

Installation
------------

[](#installation)

Composer is preferred to install Devhelp/Hash, please check [composer website](http://getcomposer.org) for more information.

```
$ composer require 'devhelp/hash:dev-master'

```

Purpose
-------

[](#purpose)

Devhelp/Hash introduces HashGenerator class that can be used to register and use different hash algorithms. It supports all PHP core hash algorithms by default, but you can register custom ones as \\Closure or Devhelp\\Hash\\Algorithm\\HashAlgorithmInterface

Usage
-----

[](#usage)

### Using built-in php core algorithms

[](#using-built-in-php-core-algorithms)

it uses [hash function](http://www.php.net/manual/en/function.hash.php) under the hood

```
$generator = new \Devhelp\Hash\HashGenerator();

$generator->generate('sha256', 'some_data'); // returns hash generated by sha256 algorithm

$generator->generate('sha256', 'some_data', array('raw_output' => true);

```

### Registering custom algorithms

[](#registering-custom-algorithms)

```
class CustomHashAlgorithm implements \Devhelp\Hash\Algorithm\HashAlgorithmInterface
{
    public function hash($data, array $options = array())
    {
        //...
    }
}

$myAlgorithm = new CustomHashAlgorithm();
$myClosure = function ($data, $options) {
    //...
};

$generator = new \Devhelp\Hash\HashGenerator();

$generator->register('my_algorithm', $myAlgorithm);
$generator->register('my_closure', $myClosure);

$generator->generate('my_algorithm', 'some_data'); //returns hash generated by CustomHashAlgorithm class
$generator->generate('my_closure', 'some_data'); //returns hash generated by $myClosure \Closure

```

### Overriding built-in PHP core algorithms

[](#overriding-built-in-php-core-algorithms)

Only thing to do is to define custom algorithm and register in under the same name as the core algorithm

```
$generator = new \Devhelp\Hash\HashGenerator();

$generator->register('sha512', new CustomHashAlgorithm());

$generator->generate('sha512', $data); //returns hash generated by CustomHashAlgorithm class

```

Credits
-------

[](#credits)

Brought to you by : [Devhelp.pl](http://devhelp.pl)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4253d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1479355?v=4)[devhelp](/maintainers/devhelp)[@devhelp](https://github.com/devhelp)

---

Top Contributors

[![pawelbaranski](https://avatars.githubusercontent.com/u/219097?v=4)](https://github.com/pawelbaranski "pawelbaranski (6 commits)")

---

Tags

hash

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/devhelp-hash/health.svg)

```
[![Health](https://phpackages.com/badges/devhelp-hash/health.svg)](https://phpackages.com/packages/devhelp-hash)
```

###  Alternatives

[hashids/hashids

Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers

5.5k48.6M278](/packages/hashids-hashids)[torann/hashids

Laravel package for Hashids

54335.1k](/packages/torann-hashids)[delight-im/ids

Short, obfuscated and efficient IDs for PHP

289.5k1](/packages/delight-im-ids)[light/hashids

Hashids for Yii2

1120.2k](/packages/light-hashids)[bvdputte/kirby-fingerprint

Cache-busting utility to fingerprint assets (JS/CSS) in Kirby 3

1610.0k](/packages/bvdputte-kirby-fingerprint)[paragonie/blakechain

Hash chain using BLAKE2b

242.9k3](/packages/paragonie-blakechain)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
