PHPackages                             delight-im/ids - 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. delight-im/ids

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

delight-im/ids
==============

Short, obfuscated and efficient IDs for PHP

v1.0.1(9y ago)289.5k↓50%21MITPHPPHP &gt;=5.6.0

Since Sep 8Pushed 8y ago2 watchersCompare

[ Source](https://github.com/delight-im/PHP-IDs)[ Packagist](https://packagist.org/packages/delight-im/ids)[ Docs](https://github.com/delight-im/PHP-IDs)[ RSS](/packages/delight-im-ids/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

PHP-IDs
=======

[](#php-ids)

Short, obfuscated and efficient IDs for PHP

No database changes are required. The original (integer) IDs are all you need.

No collisions. Reversible.

Why do I need this?
-------------------

[](#why-do-i-need-this)

- Don't leak information to your competitors (e.g. number of orders, sign-ups per day)
- Prevent resource enumeration by waiving sequential IDs
- Mix up IDs a little bit in order to make guessing them harder
- Security through obscurity

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

[](#requirements)

- PHP 5.6.0+
    - GMP extension

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

[](#installation)

1. Include the library via Composer [\[?\]](https://github.com/delight-im/Knowledge/blob/master/Composer%20(PHP).md):

    ```
    $ composer require delight-im/ids

    ```
2. Include the Composer autoloader:

    ```
    require __DIR__ . '/vendor/autoload.php';
    ```

Usage
-----

[](#usage)

### Creating an instance

[](#creating-an-instance)

```
$generator = new \Delight\Ids\Id();
```

### Encoding and decoding IDs

[](#encoding-and-decoding-ids)

```
$generator->encode(6); // => "43Vht7"
$generator->decode('43Vht7'); // => 6
```

### Shortening a number without obfuscating it

[](#shortening-a-number-without-obfuscating-it)

```
$generator->shorten(3141592); // => "vJST"
$generator->unshorten("vJST"); // => 3141592
```

### Obfuscating a number without shortening it

[](#obfuscating-a-number-without-shortening-it)

```
$generator->obfuscate(42); // => 958870139
$generator->deobfuscate(958870139); // => 42
```

Customization
-------------

[](#customization)

1. Shuffle the characters of the alphabet that is used for the base conversion. Calling `\Delight\Ids\Id::createRandomAlphabet()` may be helpful for that purpose. You might also change the alphabet entirely, but there's usually no need to do that.
2. Pass your new alphabet to the constructor as the first argument.
3. Clone this repository and then execute the file [`tests/index.php`](tests/index.php) to generate your custom prime number, inverse prime and random number for Knuth's multiplicative hashing.
4. Pass your three new numbers to the constructor as the second, third and fourth argument, respectively.

Contributing
------------

[](#contributing)

All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.

License
-------

[](#license)

This project is licensed under the terms of the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

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 ~2 days

Total

2

Last Release

3537d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cabc03c705598aed200d843d4e5b1c6350729b060cc61ec8a1bb14e02e5c0a32?d=identicon)[delight-im](/maintainers/delight-im)

---

Top Contributors

[![ocram](https://avatars.githubusercontent.com/u/1681478?v=4)](https://github.com/ocram "ocram (9 commits)")

---

Tags

hashencodedecodeidshashidsobfuscatehashidshortenidobfuscation

### Embed Badge

![Health badge](/badges/delight-im-ids/health.svg)

```
[![Health](https://phpackages.com/badges/delight-im-ids/health.svg)](https://phpackages.com/packages/delight-im-ids)
```

###  Alternatives

[hashids/hashids

Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers

5.4k48.6M278](/packages/hashids-hashids)[sqids/sqids

Generate short YouTube-looking IDs from numbers

5781.4M33](/packages/sqids-sqids)[jenssegers/optimus

Id obfuscation based on Knuth's integer hash method

1.3k4.8M27](/packages/jenssegers-optimus)[elfsundae/laravel-hashid

A simple, elegant way to obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.

415246.3k2](/packages/elfsundae-laravel-hashid)[cybercog/laravel-optimus

An Optimus bridge for Laravel. Id obfuscation based on Knuth's multiplicative hashing method.

192564.1k](/packages/cybercog-laravel-optimus)[torann/hashids

Laravel package for Hashids

54335.1k](/packages/torann-hashids)

PHPackages © 2026

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