PHPackages                             mindplay/keypack - 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. mindplay/keypack

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

mindplay/keypack
================

Pack/unpack integer and GUID keys to shorter strings

1.0.0(9y ago)419MITPHPPHP &gt;=5.4

Since Aug 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/mindplay-dk/keypack)[ Packagist](https://packagist.org/packages/mindplay/keypack)[ RSS](/packages/mindplay-keypack/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

mindplay/keypack
================

[](#mindplaykeypack)

This library packs integer, UUID and GUID keys to shorter strings, e.g. for use in user-facing URLs.

[![PHP Version](https://camo.githubusercontent.com/581d3b86ad2a67effa63792b85b18395acbbc26aae6ab4a453ed555677b8761c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d352e342532422d626c75652e737667)](https://packagist.org/packages/mindplay/keypack)[![Build Status](https://camo.githubusercontent.com/ea6702d1eda78c2fb9ece8e73673c885afe07ac3bcea72a75b1c9a20fac35362/68747470733a2f2f7472617669732d63692e6f72672f6d696e64706c61792d646b2f6b65797061636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mindplay-dk/keypack)

#### Usage

[](#usage)

Three classes, `IntPacker`, `UUIDPacker` and `GUIDPacker` are provided, each capable of packing/unpacking a particular type of ID. Each class has essentially the same interface, but accepting/returning different types of keys.

Here's an example of packing/unpacking a UUID to a shorter string:

```
$packer = new UUIDPacker();

echo $packer->pack("7eb6de1e-65ef-4fb7-baff-c0732c1c4614"); // => "py6dWN6dgKR8cGVz73zDiT"

echo $packer->unpack("py6dWN6dgKR8cGVz73zDiT"); // => "7eb6de1e-65ef-4fb7-baff-c0732c1c4614"
```

You can pack keys using different notations. The default is `legible`, which produces human-readable and reasonably short keys - [see here for more options](https://github.com/mindplay-dk/nbase).

You can also add redundancy to packed keys, to prevent typos make it harder to guess a packed key.

Here's an example packing an integer key to `base64` with 4 bytes of redundancy:

```
$packer = new IntPacker('base64');

$packer->setRedundancy(4, 'super secret salt');

echo $packer->pack(123456); // => "7yg6HR"

echo $packer->unpack("7yg6HR"); // => (int) 123456
```

Note that `unpack()` will return `null` if the redundancy check fails.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3605d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9445f567f43ee7a963270651e40e533634586f959e4df3d5398d001b1cb49be8?d=identicon)[mindplay.dk](/maintainers/mindplay.dk)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (2 commits)")

### Embed Badge

![Health badge](/badges/mindplay-keypack/health.svg)

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

###  Alternatives

[stevebauman/hypertext

The best HTML to text transformer

171539.3k2](/packages/stevebauman-hypertext)[creativestyle/magesuite-magepack

Module responsible for handling advanced JavaScript bundling.

821.9M](/packages/creativestyle-magesuite-magepack)

PHPackages © 2026

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