PHP code example of butterfly-team / avalanche-cb58
1. Go to this page and download the library: Download butterfly-team/avalanche-cb58 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
butterfly-team / avalanche-cb58 example snippets
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 */
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();
}
php
$base58 = new Tuupola\Base58;
$encoded = $base58->encode(random_bytes(128));
$decoded = $base58->decode($encoded);
php
$integer = $base58->encodeInteger(987654321); /* 1TFvCj */
print $base58->decodeInteger("1TFvCj", true); /* 987654321 */
php
$string = $base58->encode("987654321"); /* gE62MGeOBMPt */
$integer = $base58->encodeInteger(987654321); /* 1TFvCj */
php
use Tuupola\Base58Proxy as Base58;
$encoded = Base58::encode(random_bytes(128));
$decoded = Base58::decode($encoded);