PHP code example of ierusalim / baseconvert

1. Go to this page and download the library: Download ierusalim/baseconvert 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/ */

    

ierusalim / baseconvert example snippets


use ierusalim\BaseConvert;

$bc = new BaseConvert;

$hex = "43786437856abcdef";
$b58 = $bc->hextobase58($hex);

echo "$hex => base58: $b58";

use ierusalim\BaseConvert;

$bc = new vc85();

$str = "One day I'm gonna fly away One day when heavens calls my name";
$enc = $bc->vc85_encode($str);

echo "result: $enc \n";

// result: RkШжцYNQлAPjhWЮZLжz9XJZEЯeФ3nVXTБЮДbgГЧ3XTБЯVZnЯ67ZnЮtЦYrЯpJXФШGБd0BUdAbЮu81G

$back = $bc->vc85_decode($enc);

echo ($str === $back) ? "OK" : "Fail";

    public $bases = [
        2 => '01',
        3 => '012',
        4 => '0123',
        8 => '01234567',
        10 => '0123456789',
        16 => '0123456789abcdef',
        58 => '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
    ];