PHPackages                             yohns/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. yohns/hash

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

yohns/hash
==========

A simple hashing technique for forms

0.5.0(1y ago)03MITPHP

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Yohn/Hash)[ Packagist](https://packagist.org/packages/yohns/hash)[ RSS](/packages/yohns-hash/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Hash Library
============

[](#hash-library)

A secure and efficient PHP library for generating, validating, and managing tokens.

---

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

[](#installation)

Install the package via Composer:

```
composer require yohns/hash
```

---

Usage
-----

[](#usage)

### 1. Generating a Token

[](#1-generating-a-token)

Use the `generateToken` method to create a secure token.

```
use Yohns\Security\Finding\Hash;

$token = Hash::generateToken('form-id'); // This value will be used again to validate the token
// add token to form
echo '';
```

---

### 2. Validating a Token

[](#2-validating-a-token)

Verify the validity of a token with the `validateToken` method.

```
use Yohns\Security\Finding\Hash;

$isValid = Hash::validateToken('form-id', $_POST['YohnsPatch']);
if ($isValid) {
	echo 'Token is valid!';
} else {
	echo 'Token is invalid or expired.';
}
```

---

### 3. Garbage Collection

[](#3-garbage-collection)

Remove expired tokens to maintain optimal performance.

```
use Yohns\Security\Finding\Hash;

Hash::garbageCollect();
echo 'Expired tokens removed.';
```

---

Running Tests
-------------

[](#running-tests)

Ensure everything works as expected by running the test suite:

```
composer test
```

---

Requirements
------------

[](#requirements)

- PHP 8.1 or later, 8.3 preferred
- Composer
- [Yohns\\Core\\Config](https://github.com/Yohn/Config)

---

License
-------

[](#license)

This library is licensed under [MIT License](LICENSE).

---

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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

587d ago

### Community

Maintainers

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

---

Top Contributors

[![Yohn](https://avatars.githubusercontent.com/u/2002591?v=4)](https://github.com/Yohn "Yohn (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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