PHPackages                             samsonkwiz/idobfuscator - 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. samsonkwiz/idobfuscator

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

samsonkwiz/idobfuscator
=======================

Reversible numeric ID obfuscation for PHP using BCMath

v1.0.0(11mo ago)15MITPHPPHP &gt;=7.0

Since May 19Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/samsonkwiz/idobfuscator)[ Packagist](https://packagist.org/packages/samsonkwiz/idobfuscator)[ RSS](/packages/samsonkwiz-idobfuscator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

IDObfuscator for PHP
====================

[](#idobfuscator-for-php)

Secure, reversible numeric ID obfuscation for PHP using BCMath.

IDObfuscator lets you:

- Generate unpredictable numbers for tokens, card numbers, and references.
- Mask your database auto-increment IDs with deterministic, non-sequential values.
- Protect sensitive numeric identifiers in URLs, APIs, and logs.

Thanks to BCMath, it handles arbitrarily large integers and guarantees exact round-trip encoding/decoding.

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

[](#requirements)

- PHP 7.0 or higher
- BCMath extension (ext-bcmath)

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

[](#installation)

Install via Composer (recommended):

```
composer require samsonkwiz/idobfuscator
```

### Other installation methods

[](#other-installation-methods)

**1. Clone the repository and install dependencies**

```
git clone https://github.com/samsonkwiz/idobfuscator.git
cd idobfuscator
composer install
```

**2. Download ZIP**

- Go to
- Click **"Code" → "Download ZIP"**, extract the archive
- Ensure Composer autoloader is available or include source files manually

**3. Git submodule**

```
git submodule add https://github.com/samsonkwiz/idobfuscator.git path/to/IDObfuscator
```

Then update your project's `composer.json` autoload section:

```
"autoload": {
  "psr-4": {
    "SamsonKwiz\\IDObfuscator\\": "src/"
  }
}
```

Run:

```
composer dump-autoload
```

**4. Packagist**

The package is now available on Packagist. Simply run:

```
composer require samsonkwiz/idobfuscator
```

Usage## Usage
-------------

[](#usage-usage)

1. **Include Composer’s autoloader**

    ```
    require __DIR__ . '/vendor/autoload.php';
    ```
2. **Import the class**

    ```
    use SamsonKwiz\IDObfuscator\IDObfuscator;
    ```
3. **Instantiate and encode/decode IDs**

    **A. Using instance methods**

    ```
    // Create a new obfuscator instance with default settings
    $obfuscator = new IDObfuscator();

    $originalId = 12345;
    $encoded    = $obfuscator->encode($originalId);   // e.g. "004829374"
    $decoded    = $obfuscator->decode($encoded);     // back to 12345

    echo "ID {$originalId} → {$encoded} → {$decoded}";
    ```

    **B. Using static helper methods**

    ```
    $originalId = 54321;
    $encoded    = IDObfuscator::obfuscate($originalId);
    $decoded    = IDObfuscator::deobfuscate($encoded);

    echo "ID {$originalId} → {$encoded} → {$decoded}";
    ```
4. **Customize salt, key, and output length** (optional)

    ```
    $salt     = '246802468';
    $key      = '13579135';
    $length   = 12;  // exact length of the obfuscated string

    // Create a custom obfuscator
    $customOb = new IDObfuscator($salt, $key, $length);

    $id       = 98765;
    $encoded  = $customOb->encode($id);
    $decoded  = $customOb->decode($encoded);

    echo "Custom ID {$id} → {$encoded} → {$decoded}";
    ```

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

[](#contributing)

Contributions are welcome! Please fork the repository and open a pull request.

License
-------

[](#license)

This library is released under the MIT License.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance53

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/010caab1715c12cfd4438653c2f30eb6896078c7b94883b6ec94767bbcfff618?d=identicon)[samsonkwiz](/maintainers/samsonkwiz)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/samsonkwiz-idobfuscator/health.svg)

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

###  Alternatives

[fideloper/proxy

Set trusted proxies for Laravel

7.3k174.4M550](/packages/fideloper-proxy)[fakerphp/faker

Faker is a PHP library that generates fake data for you.

3.9k358.5M3.4k](/packages/fakerphp-faker)[consolidation/robo

Modern task runner

2.7k62.9M408](/packages/consolidation-robo)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k27.7M67](/packages/jetbrains-phpstorm-stubs)[illuminate/support

The Illuminate Support package.

583107.1M34.3k](/packages/illuminate-support)

PHPackages © 2026

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