vietstars / base58
Base58 encoder and decoder for arbitrary data
v0.0.3
2023-12-25 07:58 UTC
Requires
- php: ^7.4|^8.0
Requires (Dev)
- phpunit/phpunit: ^7.0|^8.0|^9.0
- squizlabs/php_codesniffer: ^3.0
Suggests
- ext-gmp: GMP extension provides the fastest encoding and decoding.
README
Install
$ composer require vietstars/base58
Usage
$base58 = new Vietstars\Base58; $encoded = $base58->encode(random_bytes(256)); $decoded = $base58->decode($encoded);
If you are encoding to and from integer use the implicit decodeInteger() and encodeInteger() methods.
$integer = $base58->encodeInteger(987654321); print $base58->decodeInteger("1TFvCj", true);
Also note that encoding a string and an integer will yield different results.
$string = $base58->encode("987654321"); $integer = $base58->encodeInteger(987654321);