PHPackages                             laragear/fingerprint - 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. laragear/fingerprint

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

laragear/fingerprint
====================

Ridiculously fast non-cryptographic hashes in your application or Eloquent Models

v3.0.0(1mo ago)131MITPHPPHP ^8.3CI passing

Since Jul 22Pushed 2mo agoCompare

[ Source](https://github.com/Laragear/Fingerprint)[ Packagist](https://packagist.org/packages/laragear/fingerprint)[ Fund](https://github.com/sponsors/DarkGhostHunter)[ Fund](https://paypal.me/darkghosthunter)[ RSS](/packages/laragear-fingerprint/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (6)Used By (0)

Fingerprint
===========

[](#fingerprint)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a89c1c01fe7a0f855d4b8c1ccc4f54789b37c8f58bbfa48600e19452f116f242/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c617261676561722f66696e6765727072696e742e737667)](https://packagist.org/packages/laragear/fingerprint)[![Latest stable test run](https://github.com/Laragear/Fingerprint/actions/workflows/php.yml/badge.svg)](https://github.com/Laragear/Fingerprint/actions/workflows/php.yml)[![Codecov coverage](https://camo.githubusercontent.com/ec5cff5ffac5dd1c807e4825e8828f4b59909053fba110ed246793cbf3a1de87/68747470733a2f2f636f6465636f762e696f2f67682f4c617261676561722f46696e6765727072696e742f67726170682f62616467652e7376673f746f6b656e3d6c4f7975384634454863)](https://codecov.io/gh/Laragear/Fingerprint)[![Maintainability](https://camo.githubusercontent.com/c691a1803a659f583f86b44d798b89011f19e090eb94488bce89446bb5ff3190/68747470733a2f2f716c74792e73682f67682f4c617261676561722f70726f6a656374732f46696e6765727072696e742f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/Laragear/projects/Fingerprint)[![Sonarcloud Status](https://camo.githubusercontent.com/85bbddec971c19efa0e57be9a1a7d122a50a536f019e3d4391fe91aa10717313/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d4c617261676561725f46696e6765727072696e74266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=Laragear_Fingerprint)[![Laravel Octane Compatibility](https://camo.githubusercontent.com/70359a356da237cd29561bc5d0bb80baae775b5ff62f288ed324755382858342/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2532304f6374616e652d436f6d70617469626c652d737563636573733f7374796c653d666c6174266c6f676f3d6c61726176656c)](https://laravel.com/docs/12.x/octane#introduction)

Ridiculously fast non-cryptographic hashes in your application or Eloquent Models.

```
use Laragear\Fingerprint\Fingerprint;

$fingerprint = Fingerprint::of('some-string-or-object');

return $fingerprint->hash();
```

Become a sponsor
----------------

[](#become-a-sponsor)

[![](.github/assets/support.png)](https://github.com/sponsors/DarkGhostHunter)

Your support allows me to keep this package free, up-to-date and maintainable.

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

[](#requirements)

- PHP 8.3 or later
- Laravel 12 or later

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

[](#installation)

You can install the package via Composer.

```
composer require laragear/fingerprint
```

How does this work?
-------------------

[](#how-does-this-work)

This utility creates non-cryptographic fingerprint hashes of strings, `Stringable` instance, resources, or any object in a memory-efficient way. It leverages the power of [`hash_init()`](https://www.php.net/manual/function.hash-init.php) and `json_encode` to hash anything, including Eloquent Models or Collections, and uses the fastest hash algorithm around, [`xxHash`](https://xxhash.com/).

Usage
-----

[](#usage)

To instance a Fingerprint, you may use the `of()` static method, which will automatically create an instance for the given string.

```
use Laragear\Fingerprint\Fingerprint;

$fingerprint = Fingerprint::of('string')
```

The Fingerprint instance is not limited to strings. You can shove in anything that can be encoded into JSON, like Eloquent Models, or *traversable* objects, like resource streams or Lazy Collections.

```
use App\Models\Article;
use Laragear\Fingerprint\Fingerprint;

$fingerprint = Fingerprint::of(
    Article::latest()->select(['id', 'body'])->lazy(50)
);
```

Once done, you may retrieve the fingerprint hash encoded in Base64 using `hash()`, or just casting the Fingerprint as a string wherever you require.

```
use Laragear\Fingerprint\Fingerprint;

$fingerprint = Fingerprint::of($text);

return "This is the article fingerprint: [$fingerprint]."
```

### Rehashing

[](#rehashing)

The Fingerprint hash is generated on demand and cached inside the Fingerprint instance. If the value is an object and it changes, the hash will remain the same.

To avoid this, you may use a callback that returns the value to hash. Everytime the hash is required, it will be generated anew.

```
use App\Models\Article;
use Laragear\Fingerprint\Fingerprint;

$article = Article::find(1);

$fingerprint = Fingerprint::of(fn () => $article->body);
```

Note

Because the hash is generated every time is required, you may want to save the hash into a variable to avoid hashing large values, and retrieving a new hash only when needed.

### Formats

[](#formats)

By default, the Fingerprint hash returned is encoded in Base64 for portability. You may retrieve the hash in other formats using the available methods:

MethodDescriptionExample`raw()`Returns the hash as a binary string`���...``hash()`, `base64()`Returns the hash encoded in Base64`dGV+z/dA==``base64UrlSafe()`Returns the hash encoded in Base64 and URL-Safe characters`dGV-z_dA``hex()`Returns the hash encoded in hexadecimal`38d1ffa8...`You may change the default format using the `Laragear\Fingerprint\Fingerprint::$as` with the Format enum of choice. You may do this while your application boots in your `App\Providers\AppServiceProvider` or `bootstrap\app.php`.

```
use Illuminate\Foundation\Application;
use Laragear\Fingerprint\Enums\Format;
use Laragear\Fingerprint\Fingerprint;

return Application::configure(basePath: dirname(__DIR__))
    ->booted(function () {
        Fingerprint::$as = Format::AsHex;
    })
    ->create();
```

This may also be changed on a per-instance basis using as `as()`.

```
use Laragear\Fingerprint\Enums\Format;
use Laragear\Fingerprint\Fingerprint;

$fingerprint = Fingerprint::of($value)->as(Format::AsHex);
```

### Algorithms

[](#algorithms)

By default, Fingerprints are hashed using the [`xxh3` algorithm](https://xxhash.com/), [available since PHP 8.1](https://www.php.net/manual/migration81.new-features.php#migration81.new-features.hash.xxhash), which is the fastest non-cryptographic algorithm around and returns short hashes.

You may change it using the second parameter when creating a Fingerprint instance, and custom options to be passed to `hash_init()`.

```
use Laragear\Fingerprint\Fingerprint;

// When instancing the object...
$fingerprint = Fingerprint::of($value, 'xxh128', [
    'seed' => 33
]);

// ...or afterwards.
$fingerprint->use('xxh128', ['seed' => 33]);
```

You may also change the default algorithm for the Fingerprint instances through the `$use` static property.

```
use Laragear\Fingerprint\Fingerprint;

Fingerprint::$use = 'xxh128';
```

Note

The algorithms available will depend on your environment. You may check them using `hash_algos()`.

Eloquent Models
---------------

[](#eloquent-models)

You can use the `Laragear\Fingerprint\Casts\AsFingerprint` cast in any of your model attributes to create a Fingerprint instance based on one or more attributes from the model, and save the resulting hash into the database.

```
use Illuminate\Database\Eloquent\Model;
use Laragear\Fingerprint\Casts\AsFingerprint;

/**
 * @property \Laragear\Fingerprint\Fingerprint $fingerprint
 */
class Article extends Model
{
    /**
     * Get the attributes that should be cast.
     *
     * @return array
     */
    public function casts()
    {
        return [
            'fingerprint' => AsFingerprint::of('body'),
        ];
    }
}
```

Note

The `AsFingerprint` cast doesn't support hash options. If you require custom options, consider using an [Eloquent accessor/mutator](https://laravel.com/docs/12.x/eloquent-mutators#accessors-and-mutators) instead.

The cast also supports using a custom algorithm and format through the second and third argument. The Cast configuration will override the default algorithm and format, and these will be respected when retrieving or saving the Fingerprint instance.

```
use Laragear\Fingerprint\Casts\AsFingerprint;
use Laragear\Fingerprint\Enums\Format;

AsFingerprint::of(['title', 'body'], 'sha256', Format::AsBase64UrlSafe)
```

Note

The Fingerprint instance returned by `AsFingerprint` uses a [callback to return the value to hash](#rehashing), meaning, the hash will be regenerated each time is required.

Serialization
-------------

[](#serialization)

> \[!DANGER\]
>
> Fingerprint instances are not safely serializable. If you require serializing a Fingerprint into storage, transform it as a string.

Laravel Octane compatibility
----------------------------

[](#laravel-octane-compatibility)

- There are no singletons using a stale app instance.
- There are no singletons using a stale config instance.
- There are no singletons using a stale request instance.
- There are no static properties written during a request.

There should be no problems using this package with Laravel Octane.

Security
--------

[](#security)

If you discover any security-related issues, issue a [Security Advisor](https://github.com/Laragear/Fingerprint/security/advisories/new)

License
=======

[](#license)

This specific package version is licensed under the terms of the [MIT License](LICENSE.md), at the time of publishing.

[Laravel](https://laravel.com) is a Trademark of [Taylor Otwell](https://github.com/TaylorOtwell/). Copyright © 2011–2026 Laravel LLC.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance88

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Every ~50 days

Recently: every ~62 days

Total

6

Last Release

47d ago

Major Versions

1.x-dev → 2.x-dev2026-03-08

v2.0.0 → 3.x-dev2026-03-30

PHP version history (2 changes)v1.0.0PHP ^8.2

2.x-devPHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![DarkGhostHunter](https://avatars.githubusercontent.com/u/5141911?v=4)](https://github.com/DarkGhostHunter "DarkGhostHunter (14 commits)")

### Embed Badge

![Health badge](/badges/laragear-fingerprint/health.svg)

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

###  Alternatives

[psmb/createnodebutton

Create the nodes in Neos even without the tree...

151.2k](/packages/psmb-createnodebutton)

PHPackages © 2026

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