PHP code example of lessmore92 / base-x

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

    

lessmore92 / base-x example snippets




use Lessmore92\BaseX\BaseX;

$rippleAlphabet = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz';
$basex          = new BaseX($rippleAlphabet);

//Ripple Address Encode/Decode
$addressDecode = $basex->decode('r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ');
var_dump($addressDecode->getHex());    // 005B812C9D57731E27A2DA8B1830195F88EF32A3B6FCBFC92D

$addressEncode = $basex->encode($addressDecode);
var_dump($addressEncode); // r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ

//Ripple Seed Encode/Decode
$seedDecode = $basex->decode('sp5fghtJtpUorTwvof1NpDXAzNwf5');
var_dump($seedDecode->getHex());    // 210102030405060708090A0B0C0D0E0F10208988A1

$seedEncode = $basex->encode($seedDecode);
var_dump($seedEncode); // sp5fghtJtpUorTwvof1NpDXAzNwf5