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

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

xobotyi/basen
=============

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

v1.0.0(7y ago)1219.6k↑87.5%3[1 PRs](https://github.com/xobotyi/basen/pulls)MITPHPPHP &gt;=7.1CI failing

Since Jun 29Pushed 5y ago1 watchersCompare

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

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

BaseN
=====

[](#basen)

 [ ![License](https://camo.githubusercontent.com/200f22c66cd82b954f2860b5496a5970290c9184f90ba564f6792b664cbdfc63/68747470733a2f2f706f7365722e707567782e6f72672f786f626f7479692f626173656e2f6c6963656e7365) ](https://packagist.org/packages/xobotyi/basen) [ ![PHP 7 ready](https://camo.githubusercontent.com/ef27b54df8bdd85d9f4aaa7481aee91fa7ca9899339cf36d95b31d5b87707a16/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f786f626f7479692f626173656e2f62616467652e737667) ](https://packagist.org/packages/xobotyi/basen) [ ![Build Status](https://camo.githubusercontent.com/3e1193f683d782af43b9925cfe43a301d822a79f18a3f0be6a100f58b609da2a/68747470733a2f2f7472617669732d63692e6f72672f786f626f7479692f626173656e2e7376673f6272616e63683d6d6173746572) ](https://travis-ci.org/xobotyi/basen) [ ![Codacy Grade](https://camo.githubusercontent.com/fcb5d2b1313d858062f2c1a2d9d8208b6832aee393917ba3c064311c8029b991/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3462383763373436643864313461373061316163333939633438666164363464) ](https://www.codacy.com/app/xobotyi/basen) [ ![Codacy Coverage](https://camo.githubusercontent.com/1244374d43c25ad8705bbe3c4b6235eeeb80130a2a6841abd4f82ed344f71498/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f3462383763373436643864313461373061316163333939633438666164363464) ](https://www.codacy.com/app/xobotyi/basen) [ ![Latest Stable Version](https://camo.githubusercontent.com/1f38cde9a88f73b449c3cea8d121f060a38c6e2ef15a872fad48a0ecc7e37343/68747470733a2f2f706f7365722e707567782e6f72672f786f626f7479692f626173656e2f762f737461626c65) ](https://packagist.org/packages/xobotyi/basen) [ ![Total Downloads](https://camo.githubusercontent.com/88c33ff1106042e1545fcf3fe70ce79b00ff583d332ada92383ac2596cd40643/68747470733a2f2f706f7365722e707567782e6f72672f786f626f7479692f626173656e2f646f776e6c6f616473) ](https://packagist.org/packages/xobotyi/basen)

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/) 7.1+

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

[](#installation)

Install with composer

```
composer require xobotyi/basen
```

Usage
-----

[](#usage)

```
use xobotyi\basen\BaseN;
use xobotyi\basen\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

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

2880d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6178739?v=4)[Anton Zinovyev](/maintainers/xobotyi)[@xobotyi](https://github.com/xobotyi)

---

Top Contributors

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

---

Tags

base16base32base36base58base62base64binaryencodingphp7rfc4648textencodingbase64rfc4648base32textbase16binarybase62base58base36

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[delight-im/base64

Simple and convenient Base64 encoding and decoding for PHP

15158.1k6](/packages/delight-im-base64)

PHPackages © 2026

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