PHPackages                             butterfly-team/avalanche-cb58 - 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. butterfly-team/avalanche-cb58

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

butterfly-team/avalanche-cb58
=============================

Base58 encoder and decoder for arbitrary data

1.2(5y ago)0821MITPHPPHP ^7.1|^8.0

Since Jan 12Pushed 5y ago4 watchersCompare

[ Source](https://github.com/butterfly-team/avalanche-cb58)[ Packagist](https://packagist.org/packages/butterfly-team/avalanche-cb58)[ Docs](https://github.com/tuupola/base58)[ RSS](/packages/butterfly-team-avalanche-cb58/feed)WikiDiscussions 2.x Synced 2d ago

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

Base58
======

[](#base58)

This library implements Base58 encoding. In addition to integers it can encode and decode any arbitrary data. That said, Base58 is well suited for decoding big integers but is not designed to decode long portions of binary data.

[![Latest Version](https://camo.githubusercontent.com/0d8edfb2b32a8aaa415b41d8fe0401757193bf0f97abbd285dc5e70742949256/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f747575706f6c612f6261736535382e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tuupola/base58)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/03b20674f66881631ce3292bec4816f88d5429644fac4b475b1f66d9447bea79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f747575706f6c612f6261736535382f54657374732f322e783f7374796c653d666c61742d737175617265)](https://github.com/tuupola/base58/actions)[![Coverage](https://camo.githubusercontent.com/ca5425fcd6997e94288e8c1598538d7791c8dac7b5255dd3523f0cfe3538f8e5/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f747575706f6c612f6261736535382e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/tuupola/base58)

Install
-------

[](#install)

Install with [composer](https://getcomposer.org/).

```
$ composer require tuupola/base58
```

This branch requires PHP 7.1 or up. The older 1.x branch supports also PHP 5.6 and 7.0.

```
$ composer require "butterfly-team/avalanche-cb58:^1.0"
```

Usage
-----

[](#usage)

This package has both pure PHP and [GMP](http://php.net/manual/en/ref.gmp.php) based encoders. By default encoder and decoder will use GMP functions if the extension is installed. If GMP is not available pure PHP encoder will be used instead.

```
$base58 = new Tuupola\Base58;

$encoded = $base58->encode(random_bytes(128));
$decoded = $base58->decode($encoded);
```

If you are encoding to and from integer use the implicit decodeInteger() and encodeInteger() methods.

```
$integer = $base58->encodeInteger(987654321); /* 1TFvCj */
print $base58->decodeInteger("1TFvCj", true); /* 987654321 */
```

Also note that encoding a string and an integer will yield different results.

```
$string = $base58->encode("987654321"); /* gE62MGeOBMPt */
$integer = $base58->encodeInteger(987654321); /* 1TFvCj */
```

Character sets
--------------

[](#character-sets)

By default Base58 uses GMP style character set. Shortcuts are provided for [Bitcoin](https://github.com/bitcoin/bitcoin/blob/master/src/base58.cpp), [Flickr](https://www.flickr.com/groups/api/discuss/72157616713786392/), [Ripple](https://wiki.ripple.com/Accounts) and [IPFS](https://github.com/richardschneider/net-ipfs-core#base58) character sets. You can also use any custom 58 characters.

```
use Tuupola\Base58;

print Base58::GMP /* 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv */
print Base58::BITCOIN /* 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz */
print Base58::FLICKR /* 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ */
print Base58::RIPPLE /* rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz */
print Base58::IPFS /* 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz */

$default = new Base58(["characters" => Base58::GMP]);
$bitcoin = new Base58(["characters" => Base58::BITCOIN]);
print $default->encode("Hello world!"); /* 1LDlk6QWOejX6rPrJ */
print $bitcoin->encode("Hello world!"); /* 2NEpo7TZRhna7vSvL */
```

Base58Check support
-------------------

[](#base58check-support)

This library supports the [Base58Check](https://en.bitcoin.it/wiki/Base58Check_encoding) encoding used in Bitcoin addresses. Decoding validates both version and the checksum. If either of them fails a `RuntimeException` will be thrown;

```
use Tuupola\Base58;

$base58check = new Base58([
    "characters" => Base58::BITCOIN,
    "check" => true,
    "version" => 0x00
]);

print $base58check->encode("Hello world!"); /* 19wWTEnNTWna86WmtFsTAr5 */

try {
    $base58check->decode("19wWTEnNTWna86WmtFsTArX");
} catch (RuntimeException $exception) {
    /* Checksum "84fec52c" does not match the expected "84fec512" */
    print $exception->getMessage();
}
```

Speed
-----

[](#speed)

Install GMP if you can. It is much faster pure PHP encoder. Below benchmarks are for encoding `random_bytes(128)` data. BCMatch encoder is also included but it is mostly just a curiosity. It is too slow to be usable.

```
$ vendor/bin/phpbench run benchmarks/ --report=default

+-----------------------+------------------+--------------+
| subject               | mean             | diff         |
+-----------------------+------------------+--------------+
| benchGmpEncoder       | 101,832.994ops/s | 0.00%        |
| benchGmpEncoderCustom | 97,656.250ops/s  | +4.28%       |
| benchPhpEncoder       | 305.913ops/s     | +33,188.19%  |
| benchBcmathEncoder    | 32.457ops/s      | +313,643.79% |
+-----------------------+------------------+--------------+

```

Static Proxy
------------

[](#static-proxy)

If you prefer to use static syntax use the provided static proxy.

```
use Tuupola\Base58Proxy as Base58;

$encoded = Base58::encode(random_bytes(128));
$decoded = Base58::decode($encoded);
```

Testing
-------

[](#testing)

You can run tests either manually or automatically on every code change. Automatic tests require [entr](http://entrproject.org/) to work.

```
$ make test
```

```
$ brew install entr
$ make watch
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.7% 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 ~18 days

Total

4

Last Release

1893d ago

Major Versions

1.2 → 2.x-dev2021-03-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58684427?v=4)[butterfly-ops](/maintainers/butterfly-ops)[@butterfly-ops](https://github.com/butterfly-ops)

---

Top Contributors

[![tuupola](https://avatars.githubusercontent.com/u/21913?v=4)](https://github.com/tuupola "tuupola (88 commits)")[![boppy](https://avatars.githubusercontent.com/u/749141?v=4)](https://github.com/boppy "boppy (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

base58

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/butterfly-team-avalanche-cb58/health.svg)

```
[![Health](https://phpackages.com/badges/butterfly-team-avalanche-cb58/health.svg)](https://phpackages.com/packages/butterfly-team-avalanche-cb58)
```

###  Alternatives

[tuupola/base58

Base58 encoder and decoder for arbitrary data

56609.6k22](/packages/tuupola-base58)[fivefilters/readability.php

A PHP port of Readability.js

311826.8k5](/packages/fivefilters-readabilityphp)[consoletvs/profanity

PHP library to block bad words in a string

1221.0M3](/packages/consoletvs-profanity)[johnbillion/args

I don't want to get into an argument about this.

117992.9k9](/packages/johnbillion-args)[seboettg/citeproc-php

Full-featured CSL processor (https://citationstyles.org)

761.2M19](/packages/seboettg-citeproc-php)[koodimonni/composer-dropin-installer

Install packages or a few files from packages into custom paths without overwriting existing stuff.

482.6M34](/packages/koodimonni-composer-dropin-installer)

PHPackages © 2026

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