PHPackages                             atrapalo/urlcrypt - 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. atrapalo/urlcrypt

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

atrapalo/urlcrypt
=================

PHP library to securely encode and decode short pieces of arbitrary binary data in URLs.

2.0.0(7y ago)1147.6k↓46.2%4[1 PRs](https://github.com/atrapalo/URLcrypt/pulls)MITPHPPHP ^7.0

Since Mar 21Pushed 4y ago65 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

URLCrypt
========

[](#urlcrypt)

[![Latest Stable Version](https://camo.githubusercontent.com/5abd45ff1d1bbdc1609b603eb13acd113296242fa9ed5d40f5fba7aa95469063/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6174726170616c6f2f75726c63727970742e737667)](https://packagist.org/packages/atrapalo/urlcrypt)[![Minimum PHP Version](https://camo.githubusercontent.com/92added58b85fa3506ce58dab2ad94930eaf82e54245453f122f95ef804637c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e302d3838393262662e737667)](http://php.net/)[![Build Status](https://camo.githubusercontent.com/89e712b3696d805f9f513503e7c8cd207f308b317dda8c403f8fa5187c133651/68747470733a2f2f7472617669732d63692e6f72672f6174726170616c6f2f55524c63727970742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/atrapalo/URLcrypt)[![Code Coverage](https://camo.githubusercontent.com/76cdc956f6b9cd62686ea1816fe8d36311e0e696efc96fe43c46cafaaa9bdd5f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6174726170616c6f2f55524c63727970742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/atrapalo/URLcrypt/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/04f3f79de0a2c84cd3241b3e8f736fc99e33c4d6e92b490c41f4a690f5ae9d71/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6174726170616c6f2f55524c63727970742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/atrapalo/URLcrypt/?branch=master)

Ever wanted to securely transmit (not too long) pieces of arbitrary binary data in a URL? **URLCrypt** makes it easy.

This class is based on the [URLCrypt](https://github.com/aarondfrancis/URLcrypt) from Aaron Francis.

URLCrypt uses **256-bit AES symmetric encryption** to securely encrypt data, and encodes and decodes **Base 32 strings that can be used directly in URLs**.

This can be used to securely store user ids, download expiration dates and other arbitrary data like that when you access a web application from a place that doesn't have other authentication or persistence mechanisms (like cookies):

- Loading a generated image from your web app in an email
- Links that come with an expiration date (à la S3)
- Mini-apps that don't persist data on the server

**Important**: As a general guideline, URL lengths shouldn't exceed about 2000 characters in length, as URLs longer than that will not work in some browsers and with some (proxy) servers. This limits the amount of data you should store with URLCrypt.

Patches are welcome; please include tests!

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

[](#requirements)

URLCrypt requires PHP &gt;= 7.0 as well as the openssl PHP extension.

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

[](#installation)

You can install URLCrypt via Composer with `composer require atrapalo/urlcrypt` or by adding the following to your `composer.json` file:

```
{
	"require": {
		"atrapalo/urlcrypt": "^2.0"
	}
}
```

Usage
-----

[](#usage)

```
use Atrapalo\UrlCrypt;

$urlCrypt = new UrlCrypt(); // Or $urlCrypt = UrlCrypt::getInstance()

// encoding without encryption. (don't use for anything sensitive)
$encoded = $urlCrypt->encode('Atrapalo');	// --> "3f5h2ylqmfwg9"
$decoded = $urlCrypt->decode('3f5h2ylqmfwg9');	// --> "Atrapalo"

// encrypting and encoding
$key = 'bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3';
$encrypted = $urlCrypt->encrypt('Atrapalo', $key);
		// --> 'xApfAdvAxg55jvk75y5n2d26xrhv3qtgfmxAmq53mf1t5'
$decrypted = $urlCrypt->decrypt('xApfAdvAxg55jvk75y5n2d26xrhv3qtgfmxAmq53mf1t5', $key)
		// --> 'Atrapalo'
```

Note that your key has to be a lower-case hex string.

Why not Base 64?
----------------

[](#why-not-base-64)

URLCrypt uses a modified Base 32 algorithm that doesn't use padding characters, and doesn't use vowels to avoid bad words in the generated string.

Base64 results in ugly URLs, since many characters need to be URL escaped.

Development
-----------

[](#development)

Clone the repository and do a `composer install` in the root directory of the library to install the development dependencies. Run the tests with `phpunit` from the root directory.

License
-------

[](#license)

This library is licensed under the MIT License - see the `COPYING` file for details.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

3

Last Release

2748d ago

Major Versions

1.0.1 → 2.0.02018-11-09

PHP version history (2 changes)1.0.0PHP ^5.5.9|~7.0

2.0.0PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6730967?v=4)[Atrápalo](/maintainers/atrapalo)[@atrapalo](https://github.com/atrapalo)

---

Top Contributors

[![GuilleGF](https://avatars.githubusercontent.com/u/5171960?v=4)](https://github.com/GuilleGF "GuilleGF (21 commits)")[![stesla](https://avatars.githubusercontent.com/u/2293?v=4)](https://github.com/stesla "stesla (21 commits)")[![madrobby](https://avatars.githubusercontent.com/u/3390?v=4)](https://github.com/madrobby "madrobby (20 commits)")[![aarondfrancis](https://avatars.githubusercontent.com/u/881931?v=4)](https://github.com/aarondfrancis "aarondfrancis (6 commits)")[![rkallensee](https://avatars.githubusercontent.com/u/1005893?v=4)](https://github.com/rkallensee "rkallensee (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/atrapalo-urlcrypt/health.svg)

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

PHPackages © 2026

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