PHPackages                             chongyi/php-basen - 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. chongyi/php-basen

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

chongyi/php-basen
=================

Text and integers encoding utilities for PHP with no extensions dependencies. Base32, Base58, Base64 and much more!

v1.0.1(11mo ago)07MITPHPPHP &gt;=8.3CI passing

Since Jun 21Pushed 11mo agoCompare

[ Source](https://github.com/chongyi/php-basen)[ Packagist](https://packagist.org/packages/chongyi/php-basen)[ Docs](https://github.com/chongyi/php-basen)[ Patreon](https://www.patreon.com/xobotyi)[ RSS](/packages/chongyi-php-basen/feed)WikiDiscussions master Synced 1mo ago

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

PHPBaseN
========

[](#phpbasen)

[![License](https://camo.githubusercontent.com/0ef42937cffa79493fde12a08d87113162b3d5c568930cbc5b9cac28ad9972b1/687474703a2f2f706f7365722e707567782e6f72672f63686f6e6779692f7068702d626173656e2f6c6963656e7365)](https://packagist.org/packages/chongyi/php-basen)[![Build Status](https://github.com/chongyi/php-basen/actions/workflows/ci.yml/badge.svg)](https://github.com/chongyi/php-basen/actions/workflows/ci.yml)[![Codacy Badge](https://camo.githubusercontent.com/27643bf2b9ca355780df992dbd9b6f533e508d7e21f9e703a5429f87b1f31ad0/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3430386162306661663664363432363062646531393939626364376164653062)](https://app.codacy.com/gh/chongyi/php-basen/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Codacy Badge](https://camo.githubusercontent.com/b22600b5109e0807de950b872e0414e0f7364baf8057f3bde1a9fffd9f542474/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f3430386162306661663664363432363062646531393939626364376164653062)](https://app.codacy.com/gh/chongyi/php-basen/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)[![Latest Stable Version](https://camo.githubusercontent.com/1b2c325c729f79f2b852c7297746626924d26a40bbc5e67e71964d431d8807d6/687474703a2f2f706f7365722e707567782e6f72672f63686f6e6779692f7068702d626173656e2f76)](https://packagist.org/packages/chongyi/php-basen)[![Total Downloads](https://camo.githubusercontent.com/dc4b24ee6a2ef9002fac095bdbdf47d349d81dac5e255391dc26f30bd227391d/687474703a2f2f706f7365722e707567782e6f72672f63686f6e6779692f7068702d626173656e2f646f776e6c6f616473)](https://packagist.org/packages/chongyi/php-basen)

Credits
-------

[](#credits)

This repository is a fork from original [xobotyi/basen](https://github.com/xobotyi/basen), because original repository is not maintained anymore.

About
-----

[](#about)

PHP is a great language but unfortunately provides us with only one text encoding (base64) which even not URL safe. And there are no straight way to change its alphabet.
BaseN solves that problem and implements common binary-to-text algorithm for encodings whose alphabet fully covers number of bits that corresponds its length. And rough algorithm which will encode each byte separately, it is less compact but guarantee the encoding with given alphabet.
Furthermore it gives you methods to encode and decode integers themselves instead of their text representation.

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

[](#requirements)

- [PHP](//php.net/) 8.3+

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

[](#installation)

Install with composer

```
composer require chongyi/php-basen
```

Usage
-----

[](#usage)

```
use PHPBaseN\BaseN;
use PHPBaseN\Base58;

// use it for something usual
$base8 = new BaseN('01234567', false, false, false);
echo $base8->encode(16) . "\n"; // 142330
echo $base8->encodeInt(16) . "\n"; // 20

// or create your own encoder with own alphabet if needed
$myOwnEncoder = new BaseN('a123d8e4fiwnmqkl', false, true, true);
echo $myOwnEncoder->encode(16) . "\n"; // 313e
echo $myOwnEncoder->encodeInt(16) . "\n"; // 1a

// predefined encoder
echo Base58::encode(16) . "\n"; // 3hC
// or, with alternative alphabet
echo Base58::encode(16, Base58::ALPHABET_RIPPLE) . "\n"; // hkD
echo Base58::encodeInt(16) . "\n"; // G
```

Builtin encodings
-----------------

[](#builtin-encodings)

BaseN provides few classes implementing most popular encodings:

- [Base16](https://en.wikipedia.org/wiki/Base16) (0-9a-f)
- [Base32](https://en.wikipedia.org/wiki/Base32) (a-z2-7)
- [Base36](https://en.wikipedia.org/wiki/Base36) (0-9a-z)
- [Base58](https://en.wikipedia.org/wiki/Base58) (0-9A-Za-v)
- Base62 (0-9A-Za-z)
- [Base64](https://en.wikipedia.org/wiki/Base64) (0-9A-Za-z+/)
- [Base85](https://en.wikipedia.org/wiki/Base85) (!"#$%&amp;'()\*+,-./0-9:;&lt;=&gt;?@A-Z\[\]^\_`a-u)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance52

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% 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 ~0 days

Total

2

Last Release

331d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e5a593e3eea7724cec4b1056d83887fb717963f40a6ff81d8357f45f71eb0734?d=identicon)[chongyi](/maintainers/chongyi)

---

Top Contributors

[![xobotyi](https://avatars.githubusercontent.com/u/6178739?v=4)](https://github.com/xobotyi "xobotyi (21 commits)")[![chongyi](https://avatars.githubusercontent.com/u/7391880?v=4)](https://github.com/chongyi "chongyi (10 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")

---

Tags

encodingbase64rfc4648base32textbase16binarybase62base58base36

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chongyi-php-basen/health.svg)

```
[![Health](https://phpackages.com/badges/chongyi-php-basen/health.svg)](https://phpackages.com/packages/chongyi-php-basen)
```

###  Alternatives

[xobotyi/basen

Text and integers encoding utilities for PHP with no extensions dependencies. Base32, Base58, Base64 and much more!

1219.6k](/packages/xobotyi-basen)[paragonie/constant_time_encoding

Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)

903329.7M148](/packages/paragonie-constant-time-encoding)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15439.5M49](/packages/spomky-labs-base64url)[christian-riesen/base32

Base32 encoder/decoder according to RFC 4648

13331.8M61](/packages/christian-riesen-base32)[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)[ademarre/binary-to-text-php

Collection of binary-to-text encoding utilities for PHP. Includes Base32 support and much more.

40165.8k](/packages/ademarre-binary-to-text-php)

PHPackages © 2026

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