Torann / laravel-hashids by torann

Laravel package for Hashids
Package Data
Maintainer Username: torann
Maintainer Contact: (Daniel Stainback)
Package Create Date: 2014-01-24
Package Last Update: 2024-03-22
Home Page:
Language: PHP
License: BSD-2-Clause
Last Refreshed: 2024-04-17 15:03:02
Package Statistics
Total Downloads: 259,226
Monthly Downloads: 2,413
Daily Downloads: 116
Total Stars: 52
Total Watchers: 7
Total Forks: 11
Total Open Issues: 0

Hashids for Laravel 5

Latest Stable Version Total Downloads

This package uses the classes created by

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



From the command line run:

$ composer require torann/hashids

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

'providers' => [

There is no need to add the Facade, the package will add it for you.

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.

Laravel 4 Installation

Add verison 1.0 of Hashids in your composer.json file.

"torann/hashids": "1.0.*"

And following the directions in the README on version 1.0.


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


You can simply encode a single id:

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

or multiple..

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



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

or multiple..


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



  • Upgraded to Laravel 5
  • Upgraded to Hashids 1.0.5


  • Several public functions are renamed to be more appropriate:

    • Function encrypt() changed to encode()
    • Function decrypt() changed to decode()
    • Function encryptHex() changed to encodeHex()
    • Function decryptHex() changed to decodeHex()

    Hashids was designed to encode integers, primary ids at most. Hashids is the wrong algorithm to encrypt sensitive data. So to encourage more appropriate use, encrypt/decrypt is being "downgraded" to encode/decode.

  • Version tag added: 1.0

  • updated

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