PHPackages                             nassiry/laravel-encoder - 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. nassiry/laravel-encoder

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

nassiry/laravel-encoder
=======================

An advanced Laravel encoder package for string &amp; integer encoding and decoding.

1.0.1(1y ago)3348↓100%MITPHPPHP ^8.1CI passing

Since Dec 28Pushed 1y ago1 watchersCompare

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

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

Laravel Encoder Package
=======================

[](#laravel-encoder-package)

[![Tests](https://github.com/nassiry/laravel-encoder/actions/workflows/tests.yml/badge.svg)](https://github.com/nassiry/laravel-encoder/actions/workflows/tests.yml/badge.svg)[![Packagist Downloads](https://camo.githubusercontent.com/6d062b009f14fc4c21a1379eb29349b500d95be3ce42e291693bb9f2cdb6651c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6173736972792f6c61726176656c2d656e636f646572)](https://camo.githubusercontent.com/6d062b009f14fc4c21a1379eb29349b500d95be3ce42e291693bb9f2cdb6651c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6173736972792f6c61726176656c2d656e636f646572)[![Packagist Version](https://camo.githubusercontent.com/64faf035408ad50fa0cb0f2b13a55bc92177a7c7b6f413d93f2b0e364b12dc3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6173736972792f6c61726176656c2d656e636f646572)](https://camo.githubusercontent.com/64faf035408ad50fa0cb0f2b13a55bc92177a7c7b6f413d93f2b0e364b12dc3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6173736972792f6c61726176656c2d656e636f646572)[![Laravel](https://camo.githubusercontent.com/224cbca808a3313ee849ccbe5564af9397bdcf482596b0508cafae13d0bc9ba7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313025323025374325323031312d726564)](https://camo.githubusercontent.com/224cbca808a3313ee849ccbe5564af9397bdcf482596b0508cafae13d0bc9ba7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313025323025374325323031312d726564)[![PHP](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565)](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565)[![License](https://camo.githubusercontent.com/32a54a1d3f7a713fa4511a288e7ba2dfaa10d100eee38cd5b483460b4edabd6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6173736972792f6c61726176656c2d656e636f646572)](https://camo.githubusercontent.com/32a54a1d3f7a713fa4511a288e7ba2dfaa10d100eee38cd5b483460b4edabd6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6173736972792f6c61726176656c2d656e636f646572)

[![Header Image](./assets/laravel-encoder.png)](./assets/laravel-encoder.png)

The Laravel Encoder package provides a robust and secure way to `encode` and `decode` **IDs** &amp; **Strings** using customizable Base encoding mechanisms (Base62). With support for variable-length encoding, mappers for added security, and seamless integration with Laravel, this package is ideal for obfuscating sensitive data or creating URL-safe identifiers.

> ⚠️ **Note:** This package is meant for obfuscation, not encryption. Do not use it for storing or transmitting sensitive data securely.

Table Of Contents
-----------------

[](#table-of-contents)

1. [Features](#features)
2. [Requirements](#requirements)
3. [Installation](#installation)
4. [Quick Example](#quick-example)
    - [Encode &amp; Decode an ID](#encode--decode-an-id)
    - [Encode &amp; Decode a String](#encode--decode-a-string)
5. [Documentation](#documentation)
    - [Laravel Integration](#laravel-integration)
    - [Standalone PHP Usage](#standalone-php-usage)
    - [Configuration](#configuration)
    - [Custom Bases](#custom-bases)
    - [Exception Handling](#exception-handling)
    - [Testing &amp; Contributing](#testing--contributing)
6. [Why I Built This](#why-i-built-this)
7. [Why Base62?](#why-base62)
8. [Why Choose This Package?](#conclusion-why-choose-this-package)
9. [Contributing](#contributing)
10. [Changelog](#changelog)
11. [License](#license)

### Features

[](#features)

- **Base Encoding**: Supports customizable bases (Base62).
- **Variable-Length Encoding**: Allows encoding with custom lengths for obfuscation.
- **Mapper-Based Obfuscation**: Adds an extra layer of security by using configurable prime numbers and mappers.
- **Customizable Configuration**: Publish the configuration file to override default mappers.
- **Exception Handling**: Provides detailed exceptions for invalid inputs.
- **Laravel Integration**: Works seamlessly with Laravel’s service container and configuration system.
- **Security**: Protects sensitive IDs by ensuring encoded values are not easily reversible without the correct configuration.

### Requirements

[](#requirements)

- PHP 8.1 or higher
- Laravel 10 or higher (optional, for Laravel integration)
- PHP extensions: `bcmath`, `mbstring`

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

[](#installation)

**Step 1: Install via Composer**

```
composer require nassiry/laravel-encoder
```

### Quick Example

[](#quick-example)

- #### Encode &amp; Decode an ID

    [](#encode--decode-an-id)

```
use Nassiry\Encoder\Facades\Encoder;

$encoded = Encoder::encodeId(12345);
$decoded = Encoder::decodeId($encoded);

echo $encoded; // Encoded Strings
echo $decoded; // 12345
```

- #### Encode &amp; Decode a String

    [](#encode--decode-a-string)

```
$encoded = Encoder::encodeString('Hello World');
$decoded = Encoder::decodeString($encoded);

echo $encoded; // Encoded Strings
echo $decoded; // Hello World
```

### Documentation

[](#documentation)

#### Laravel Integration

[](#laravel-integration)

`Encode/decode` `strings` and `IDs` using Laravel container, facades, or dependency injection.

- [Laravel Usage](docs/laravel.md)

#### Standalone PHP Usage

[](#standalone-php-usage)

Use in any PHP project, no Laravel required.

- [Standalone Guide](docs/standalone.md)

#### Configuration

[](#configuration)

Customize encoding behavior, mappers, and defaults.

- [Configuration Guide](docs/configuration.md)

#### Custom Bases

[](#custom-bases)

Add your own Base58, Base64, or custom encoders.

- [Custom Bases Guide](docs/custom-bases.md)

#### Exception Handling

[](#exception-handling)

Covers validation, decoding issues, and base errors.

- [Exception Handling](docs/exceptions.md)

#### Testing &amp; Contributing

[](#testing--contributing)

Run the test suite or contribute improvements.

- [Testing Guide](docs/testing.md)

### Why I Built This

[](#why-i-built-this)

Laravel's `encryption` produced long `strings`, and Base64 needed extra steps to be URL-safe. I wanted a clean, simple way to encode IDs and strings short, URL-safe, and easy to configure. [Full Story &amp; Benefits](docs/why.md)

### Why Base62?

[](#why-base62)

[Read the Reasoning](docs/base62.md)

### Conclusion: Why Choose This Package?

[](#conclusion-why-choose-this-package)

[ Final Thoughts](docs/conclusion.md)

### Contributing

[](#contributing)

Feel free to submit issues or pull requests to improve the package. Contributions are welcome! Let’s improve it together!

### Changelog

[](#changelog)

See [CHANGELOG](CHANGELOG.md) for release details.

### License

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance50

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

2

Last Release

384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d313e55474ce48c3b19820c784435215bb56c4497557b603583dcf59ba2270c?d=identicon)[nassiry](/maintainers/nassiry)

---

Top Contributors

[![nassiry](https://avatars.githubusercontent.com/u/105405739?v=4)](https://github.com/nassiry "nassiry (15 commits)")

---

Tags

decode62encode62encodestringlaravellaravel-base64-encoderlaravel-hashidphp-base64-encoderphp-encodeidphp-hashidhashidbase62encoderdecoderid obfuscationlaravel-hashidencode-stringdecode-stringencode-iddecode-idstring-encodingphp-encoderlaravel-encoder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nassiry-laravel-encoder/health.svg)

```
[![Health](https://phpackages.com/badges/nassiry-laravel-encoder/health.svg)](https://phpackages.com/packages/nassiry-laravel-encoder)
```

###  Alternatives

[hashids/hashids

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

5.5k48.6M275](/packages/hashids-hashids)[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)[tuupola/base62

Base62 encoder and decoder for arbitrary data

1994.3M35](/packages/tuupola-base62)[riimu/kit-phpencoder

Highly customizable alternative to var\_export for PHP code generation

717.8M32](/packages/riimu-kit-phpencoder)[tuupola/ksuid

K-Sortable Globally Unique IDs

1081.2M4](/packages/tuupola-ksuid)

PHPackages © 2026

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