PHPackages                             spoova/hasher - 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. spoova/hasher

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

spoova/hasher
=============

Package for hashing data with multiple hashing algorithm

v1.0.0(3y ago)010MITPHP

Since Mar 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/teymzz/Hasher)[ Packagist](https://packagist.org/packages/spoova/hasher)[ RSS](/packages/spoova-hasher/feed)WikiDiscussions main Synced 1mo ago

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

Hasher
======

[](#hasher)

Hasher is a php package for generating dynamic or static hashes by combining varying hashing algorithms in a specific number of times.

#### Initializing Class

[](#initializing-class)

The hasher class can be instantiated as shown below

```
include_once 'vendor/autoload.php'

use Spoova/Hasher/Hasher;

$Hasher = new Hasher;
```

#### Definining Hash Data

[](#definining-hash-data)

The data to be hashed can be defined by using the `setHash()` method using the syntax below

```
$Hasher->setHash($data, $key);
```

- `$data` : data to be hashed
- `$key` : an optional secret key.

An example of data specified to be hashed is shown below

```
$Hasher->setHash(['name' => 'foo'], 'some_secret_key');
```

#### Defining Hashing Algorithm

[](#defining-hashing-algorithm)

The `hashFunc` method is being used to define the hashing algorithm to be used for hashing a data. For example, after the `setHash()` method, we can supply a list of algorithms as below

```
$Hasher->hashFuncs(['md5', 'sha1', 'base64_encode']);
```

In the code above, each function will be used for hashing the data specified in `setHash()` method

#### Processing and obtaining static hashed data

[](#processing-and-obtaining-static-hashed-data)

In order to execute the hashing and obtain the hash data the `hashify()` method is called. This method will execute and return the hashed data.

> Process and return hashed data

```
$hash = $Hasher->hashify(); //process and return hash
```

> The `hashify()` method also takes an integer parameter which makes it possible to execute the hashing in a number of specified times.

```
$hash = $Hasher->hashify(7); //run hashing 7 times
```

#### Processing and obtaining dynamic hashed data

[](#processing-and-obtaining-dynamic-hashed-data)

While `hashify()` method returns a static hashed data by default, the returned data can be specified as dynamic through the `randomize()` method. This means that different hashed data will be generated when the `hashify()` method is called.

> Generate a random hash from specified data

```
$Hasher->randomize();
$hash = $Hasher->hashify();
```

> Generate a random hash by using dynamic functions

```
$Hasher->randomize(time());
$hash = $Hasher->hashify();
```

#### Behavioural Pattern of Hashify

[](#behavioural-pattern-of-hashify)

> The hashify function keeps track of its last state and generates a new hash once it is recalled. This means that every time `hashify()` method is called, a newly hashed data is generated from its last state. For example

```
$hash1 = $Hasher->hashify(); //new hash one
$hash2 = $Hasher->hashify(); //new hash two
$hash3 = $Hasher->hashify(); //new hash three
$hash4 = $Hasher->hashify(0); //new hash one (reset hash)
$hash5 = $Hasher->hashify(); //new hash two
```

> In the code above, the hashify will continue to generate a new data until the hash node is restarted by supplying an argument of zero(0) to the hashify method. Once the hash node is restarted the data returned will be the first hash while the subsequent called will reflect its previous pattern. We may however try to be specific in the number of calls through the argument supplied. For example:

```
$hash1 = $Hasher->hashify(); //new hash one
$hash2 = $Hasher->hashify(); //new hash two
$hash3 = $Hasher->hashify(); //new hash three

$hash4 = $Hasher->hashify(3); //new hash three
```

> In the code above the `$hash4` data will be recorded as the same data with `$hash3`. This is because `$hash3` contains a data returned after three(3) successful calls of hashify. This data matches the exact number of times supplied as argument in the `$hash4`. This means that rather than running the `hashify()` without arguments for 4 consecutive times, we can easily supply the number of specific times of hash as arguments and the corresponding data will be returned. Also, in other to prevent `hashify()` from constantly changing, the first argument supplied must be false as shown below:

```
$hash1 $Hasher->hashify(); //new hash one
$hash2 $Hasher->hashify(); //new hash twp
$hash3 $Hasher->hashify(false); //same as hash one above
```

> The hashify function also assumes a list of hash function which overides any default declared if an array is supplied as first argument

```
$hash = $Hasher->hashify(['md5', 'sha']);
```

> In cases where two arguments are supplied, the first must be integer or boolean while the second array argument should contain the hashing algorithm. For example:

```
$hash = $Hasher->hashify(false, ['md5', 'sha']);
```

#### Generate an independent random hash

[](#generate-an-independent-random-hash)

Other random hashes can be generated independently through the `randomHash()` method. This method is a stand alone method that does not depend on any other method to perform its functions.

> Generate random hash of specific length of characters

```
$hash = $Hasher->randomHash(10); //random hash string of 10 characters
```

> Generate random hash of specific length using specific range of characters

```
$hash = $Hasher->randomHash(10, 'foo'); //random hash string of 10 characters using characters in 'foo' only
```

> Generate random hash using specfied alogithms. Note that hash length can only be specified by the last algorithm used, hence the length is not applied.

```
$hash = $Hasher->randomHash("", 'foo', ['md5','sha1']); //random hash of 'foo' using specified functions.
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

1160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83e5087db5782cfe0290df66bd2871ab132d9ba620c1ac25b8e6036a71211302?d=identicon)[teymzz](/maintainers/teymzz)

---

Top Contributors

[![teymzz](https://avatars.githubusercontent.com/u/121361329?v=4)](https://github.com/teymzz "teymzz (1 commits)")

### Embed Badge

![Health badge](/badges/spoova-hasher/health.svg)

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

PHPackages © 2026

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