PHPackages                             marekweb/opaque-id - 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. marekweb/opaque-id

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

marekweb/opaque-id
==================

Opaque ID: Obfuscation scheme for integer IDs

1027.6k12[2 issues](https://github.com/marekweb/opaque-id/issues)PHP

Since Jun 6Pushed 8y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Opaque ID: Obfuscation for integer IDs
======================================

[](#opaque-id-obfuscation-for-integer-ids)

Opaque ID obfuscates integers using a reversible scheme based on a secret key.

It aims to hide resource/database IDs from observers when included in public URLs or API responses, without the need for surrogate database keys.

Here's what Opaque IDs look like:

```
      ID    Opaque Hex  Opaque Base64
       0     7ea0aa7a      fqCqeg
       1     0ae54fa3      CuVPow
       2     cbae9d6c      y66dbA
       3     db2ac148      2yrBSA

```

The algorithm is a one-to-one integer mapping (which incorporates a secret key). It's lightweight and compact, at the cost of actual cryptographic security. For real encryption, use a serious encryption algorithm instead (although you won't get such a compact ciphertext).

Usage
-----

[](#usage)

Here's how you use Opaque ID (Python example):

```
# Create an instance with your secret key (pick your own key!)
encoder = opaque.OpaqueEncoder(0x3b79db9a)

print encoder.encode_hex(3)
# -> db2ac148

print encoder.encode_base64(3)
# -> 2yrBSA

print encoder.decode_base64("2yrBSA")
# -> 3
```

Here's a PHP example

```
$encoder = new OpaqueEncoder(0x3b79db9a);
print $encoder->encode($id); // Default mode is hex

$encoder = new OpaqueEncoder(0x3b79db9a, OpaqueEncoder::ENCODING_BASE64);
print $encoder->encode($id); // Will use base64 mode
```

Install the class using composer:

```
composer require marekweb/opaque-id
```

Then require it with:

```
require 'vendor/autoload.php';
$encoder = new OpaqueEncoder(0x3b79db9a);
```

Implementations
---------------

[](#implementations)

- PHP: `OpaqueEncoder.php` class
- Python: `opaque.py` module

Authors
-------

[](#authors)

(c) 2011 Marek Z. @marekweb

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57552?v=4)[Marcelo Andrade R.](/maintainers/marceloandrader)[@marceloandrader](https://github.com/marceloandrader)

---

Top Contributors

[![marekweb](https://avatars.githubusercontent.com/u/602886?v=4)](https://github.com/marekweb "marekweb (10 commits)")[![marceloandrader](https://avatars.githubusercontent.com/u/57552?v=4)](https://github.com/marceloandrader "marceloandrader (3 commits)")[![girasquid](https://avatars.githubusercontent.com/u/60324?v=4)](https://github.com/girasquid "girasquid (2 commits)")[![kirsle](https://avatars.githubusercontent.com/u/1663507?v=4)](https://github.com/kirsle "kirsle (1 commits)")

### Embed Badge

![Health badge](/badges/marekweb-opaque-id/health.svg)

```
[![Health](https://phpackages.com/badges/marekweb-opaque-id/health.svg)](https://phpackages.com/packages/marekweb-opaque-id)
```

PHPackages © 2026

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