PHPackages                             danphyxius/hashids - 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. [Security](/categories/security)
4. /
5. danphyxius/hashids

ActiveLibrary[Security](/categories/security)

danphyxius/hashids
==================

Laravel package for Hashids

v1.3(11y ago)02311MITPHPPHP &gt;=5.4.0

Since Jul 21Pushed 11y ago1 watchersCompare

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

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

Hashids for Laravel 4
=====================

[](#hashids-for-laravel-4)

This package uses the classes created by [hashids.org](http://www.hashids.org/ "http://www.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
------------

[](#installation)

Begin by installing the package through Composer. Edit your project's `composer.json` file to require `ludo237/hashids`.

```
"require": {
  "danphyxius/hashids": "1.3"
}
```

Next use Composer to update your project from the the Terminal:

```
php composer.phar update
```

Once the package has been installed you'll need to add the service provider. Open your `app/config/app.php` configuration file, and add a new item to the `providers` array.

```
'DanPhyxius\Hashids\HashidsServiceProvider'
```

After doing this you also need to add an alias. In your `app/config/app.php` file, add this to the `aliases` array.

```
'Hashids' => 'DanPhyxius\Hashids\Hashids'
```

Now last but not least you need to publish to package configuration from your Terminal:

```
php artisan config:publish danphyxius/hashids
```

Usage
-----

[](#usage)

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

### Encrypting

[](#encrypting)

You can simply encrypt on id:

```
Hashids::encrypt(1); // Creating hash... Ri7Bi
```

or multiple..

```
Hashids::encrypt(1, 21, 12, 12, 666); // Creating hash... MMtaUpSGhdA
```

### Decrypting

[](#decrypting)

It's the same thing but the other way around:

```
Hashids::decrypt('Ri7Bi');

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

or multiple..

```
Hashids::decrypt('MMtaUpSGhdA');

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

### Injecting Hashids

[](#injecting-hashids)

Now it's also possible to have Hashids injected into your class. Lets look at this controller as an example..

```
class ExampleController extends BaseController
{
    protected $hashids;

    public function __construct(Hashids\Hashids $hashids)
    {
        $this->hashids = $hashids;
    }

    public function getIndex()
    {
        $hash = $this->hashids->encrypt(1);
        return View::make('example.index', compact('hash'));
    }
}
```

The original classname and namespace has been bound in the IoC container to return our instantiated Hashids class.

### Using IoC

[](#using-ioc)

Create a Hashids instance with the IoC

```
App::make('Hashids\Hashids')->encrypt(1);
```

That's it!
----------

[](#thats-it)

For documentation about Hashids itself, go to: .

Hopefully you'll enjoy this package and thanks to Ivan Akimov (@ivanakimov) for making Hashids. All credits for the Hashids package go to him.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 57.7% 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 ~26 days

Total

3

Last Release

4268d ago

PHP version history (2 changes)v1.1PHP &gt;=5.3.0

v1.2PHP &gt;=5.4.0

### Community

Maintainers

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

---

Top Contributors

[![mitchellvanw](https://avatars.githubusercontent.com/u/3061428?v=4)](https://github.com/mitchellvanw "mitchellvanw (41 commits)")[![ludo237](https://avatars.githubusercontent.com/u/921500?v=4)](https://github.com/ludo237 "ludo237 (15 commits)")[![DanCosta88](https://avatars.githubusercontent.com/u/4693301?v=4)](https://github.com/DanCosta88 "DanCosta88 (8 commits)")[![Garbee](https://avatars.githubusercontent.com/u/868301?v=4)](https://github.com/Garbee "Garbee (2 commits)")[![rmobis](https://avatars.githubusercontent.com/u/2119933?v=4)](https://github.com/rmobis "rmobis (2 commits)")[![tplaner](https://avatars.githubusercontent.com/u/50652?v=4)](https://github.com/tplaner "tplaner (2 commits)")[![Pasvaz](https://avatars.githubusercontent.com/u/3006580?v=4)](https://github.com/Pasvaz "Pasvaz (1 commits)")

---

Tags

laravelsecurityhashinghashids

### Embed Badge

![Health badge](/badges/danphyxius-hashids/health.svg)

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

###  Alternatives

[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

8745.6k](/packages/dgtlss-warden)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)

PHPackages © 2026

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