torann/hashids

Laravel package for Hashids

Maintainers

👁 torann

Package info

github.com/Torann/laravel-hashids

pkg:composer/torann/hashids

Statistics

Installs: 343 456

Dependents: 0

Suggesters: 0

Stars: 54

Open Issues: 0

3.0.6 2026-01-20 18:46 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-2-Clause 779303d45606533030c43004fa8436f2daa6fffd

  • Daniel Stainback <torann.woop@gmail.com>

hashencodedecodelaravelhashid

This package is auto-updated.

Last update: 2026-06-20 19:40:23 UTC


README

👁 Latest Stable Version
👁 Total Downloads

This package uses the classes created by hashids.org

Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.

Installation

Composer

From the command line run:

$ composer require torann/hashids

Without Package Auto-Discovery

Once Hashids is installed you need to register the service provider and facade with the application. Open up config/app.php and find the providers and aliases keys.

'providers' => [
 Torann\Hashids\HashidsServiceProvider::class,
]

'aliases' => [
 'Hashids' => Torann\Hashids\Facade\Hashids::class,
]

Publish the configurations

Run this on the command line from the root of your project:

$ php artisan vendor:publish --provider="Torann\Hashids\HashidsServiceProvider"

A configuration file will be publish to config/hashids.php.

Usage

Once you've followed all the steps and completed the installation you can use Hashids.

Encoding

You can simply encode a single id:

Hashids::encode(1); // Returns Ri7Bi

or multiple..

Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA

Decoding

Hashids::decode(Ri7Bi);

// Returns
array (size=1)
0 => int 1

or multiple..

Hashids::decode(MMtaUpSGhdA);

// Returns
array (size=5)
0 => int 1
1 => int 21
2 => int 12
3 => int 12
4 => int 666

All credit for Hashids goes to Ivan Akimov (@ivanakimov), thanks to for making it!