PHP code example of ocubom / base-convert

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

    

ocubom / base-convert example snippets


  use function \Ocubom\Math\base_convert;
  
  $hex = base_convert(random_bytes(32), 'bin', 'hex');
  

  use Ocubom\Math\Base\Crockford;
  use function Ocubom\Math\base_convert;
  
  // Encoding
  $crockford = base_convert(random_bytes(32), 'bin', new Crockford());

  // Decoding
  $hex = base_convert($crockford, new Crockford(), 'hex');
  

  use Ocubom\Math\Crockford;
  
  // Encoding
  $crockford = Crockford::encode(random_bytes(32), 'bin');

  // Decoding
  $hex = Crockford::decode($crockford, 'hex');
  

  use function \Ocubom\Math\crockford_decode;
  use function \Ocubom\Math\crockford_encode;
  
  // Encoding
  $crockford = crockford_encode(random_bytes(32), 'bin');

  // Decoding
  $hex = crockford_decode($crockford, 'hex');
  

  use Ocubom\Math\Base\Base58;
  use function Ocubom\Math\base_convert;
  
  // Encoding
  $base58 = base_convert(random_bytes(32), 'bin', new Base58());

  // Decoding
  $hex = base_convert($base58, new Base58(), 'hex');