Skip to content

sulaco-tech/base58-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

base58-php

Pretty lightweight implementation of Base58 encoding and deconding algorithms written in PHP.

Install

Install with composer.

$ composer require sulaco-tech/base58

Requirements

This branch requires PHP 7.0 or up.

Usage

$base58 = new SulacoTech\Base58();

$data = "Hello World!";
$encoded = $base58->encode($data); // "2NEpo7TZRRrLZSi2U"
$decoded = $base58->decode($encoded); // "Hello World!"

Character sets

Encoder support few predefined charset sets for coding algorithms:

You can also use any custom 58 characters. By default the encoder uses IPFS style character set.

use SulacoTech\Base58;

print Base58::CHARSET_GMP;
// 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv
print Base58::CHARSET_BITCOIN;
// 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
print Base58::CHARSET_FLICKR;
// 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
print Base58::CHARSET_RIPPLE;
// rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz
print Base58::CHARSET_IPFS;
// 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

$base58 = new Base58(Base58::CHARSET_FLICKR);
$data = "Hello World!";
$encoded = $base58->encode($data); // "2nePN7syqqRkyrH2t"
$decoded = $base58->decode($encoded); // "Hello World!"

Testing

You can run tests with external (global) installation of PHPUnit.

$ phpunit tests

This branch was tested on PHP:

  • 7.0.12
  • 7.1.9
  • 7.2.17
  • 7.4.3

License

This library is license under the MIT License (MIT). Please see License File for more information.

About

Pretty lightweight implementation of Base58 encoding and deconding algorithms written in PHP.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages