PHPackages                             exussum12/xxhash - 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. exussum12/xxhash

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

exussum12/xxhash
================

xxHash implementation in Pure PHP

1.3(5y ago)212.5M↓14.7%6[2 issues](https://github.com/exussum12/xxhash/issues)4BSD-2-ClausePHPPHP &gt;=7.4CI failing

Since Mar 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/exussum12/xxhash)[ Packagist](https://packagist.org/packages/exussum12/xxhash)[ RSS](/packages/exussum12-xxhash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (9)Used By (4)

A pure PHP implementation of [xxhash](https://github.com/Cyan4973/xxHash)

Currently only working for the 32 bit version. (Pre PHP 7.4). 32 and 64 bit version both work with PHP 7.4

If speed is important use the FFI versions (PHP 7.4+)

XXHash is a fast hash designed for file integrity checking. Passwords should not be hashed with this, please use Argon2 or BCrypt.

On PHP 8.1 xxhash is included by default, please use that instead

```
hash('xxh32',  'string');

```

for string mode or

```
$context = hash_init('xxh3');
hash_update($context, 'String1'); // from fgets or similar
hash_update($context, 'String2'); // from fgets or similar
hash_final($context);

```

Installing
==========

[](#installing)

With composer

```
composer require exussum12/xxhash

```

Hashing input
=============

[](#hashing-input)

xxhash has a seed, this is 0 by default. To make a new instance of xxhash run

```
use exussum12\xxhash\V32;
$seed = 0;
$hash = new V32($seed);

```

Then to hash input, run

```
$hash->hash('string'); ## to hash a string

```

or

```
$file = fopen('path/to/file.ext', 'r');
$hash->hashStream($file); # for a stream (better for large files)

```

The library can be called statically also, however this removes the ability to change the seed. The default see of 0 will be used

```
V32::hash('string'); ## to hash a string
$file = fopen('path/to/file.ext', 'r');
V32::hashStream($file); # for a stream (better for large files)

```

Static functions should in general be avoided, so the first method is the preferred method to use.

FFI
---

[](#ffi)

Since PHP 7.4 FFI allows PHP to call the native C client. This is much faster, and the preferred way if your running PHP 7.4

### Speed Comparison

[](#speed-comparison)

This is hashing a 320mb file using the stream method. The time is the time take (smaller is better)

MethodTimePeak MemoryxxHash Binary0.0811604kbFFI0.19427616kbPure PHP49.21827844kbMemory measured using `/usr/bin/time -v`

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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

Every ~72 days

Total

5

Last Release

1953d ago

PHP version history (2 changes)1.0PHP &gt;=7.1

1.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7759f1a7acac4ee25112e8e0ac2eb608010aba1060ba00c687d615dc7e74f19?d=identicon)[exussum](/maintainers/exussum)

---

Top Contributors

[![exussum12](https://avatars.githubusercontent.com/u/1102850?v=4)](https://github.com/exussum12 "exussum12 (18 commits)")[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (2 commits)")

---

Tags

hacktoberfestphpxxhash

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/exussum12-xxhash/health.svg)

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

###  Alternatives

[qazd/text-diff

A simple text differences visualization library

38121.2k1](/packages/qazd-text-diff)

PHPackages © 2026

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