PHP code example of codepower / anybase

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

    

codepower / anybase example snippets


use Anybase\Codec;
use Anybase\Alphabets;

$codec = Codec::for(Alphabets::base62());
$codec->encode(123456789);   // "8M0kX"
$codec->decode("8M0kX");     // "123456789"

use Anybase\Alphabet;

$codec = Codec::for(Alphabet::fromString('0289PYLQGRJCUV'));
$codec->encode(98765); // "8QVUR"

$codec = Codec::for(Alphabets::crockfordBase32())->withSalt(0xDEADBEEF);

$codec = Codec::for(Alphabets::base62())->withMinLength(8);
$codec->encode(42);   // "0000000g"

use Anybase\BaseConverter;

$conv = new BaseConverter(Alphabets::base16(), Alphabets::base62());
$conv->convert('deadbeef');

Alphabets::supercellHashtag();                 // default foldings + case-insensitive
Alphabets::supercellHashtag([]);               // no foldings, still case-insensitive
Alphabets::supercellHashtag(['Z' => '2']);     // custom fold map
Alphabets::supercellHashtag([], caseInsensitive: false); // strict