PHP code example of covaleski / data-encoding

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

    

covaleski / data-encoding example snippets


use Covaleski\DataEncoding\Base32;

$encoded = Base32::encode('Dunder Mifflin Paper Company, Inc.');
// Will produce: IR2W4ZDFOIQE22LGMZWGS3RAKBQXAZLSEBBW63LQMFXHSLBAJFXGGLQ=

use Covaleski\DataEncoding\Base32;

$decoded = Base32::decode('4WGZPZF2VTULPLY=');
// Will produce: 南京路

class Base4 extends Encoder
{
    protected static array $alphabet = [
        'A', 'B', 'C', 'D',
    ];
    protected static int $base = 4;
    protected static bool $isCaseSensitive = true;
}

$encoded = Base8Emoji::encode('foo');
// Will produce: BCBCBCDDBCDD

use Covaleski\DataEncoding\Encoder;

class Base8Emoji extends Encoder
{
    protected static array $alphabet = [
        '😎', 'πŸ˜”', '😳', 'πŸ’€', '🀑', 'πŸ‘€', '✊', 'πŸ’…',
    ];
    protected static int $base = 8;
    protected static string $alphabetEncoding = 'UTF-8';
    protected static bool $isCaseSensitive = false;
}

$encoded = Base8Emoji::encode('foo');
// Will produce: πŸ’€πŸ˜”πŸ€‘βœŠπŸ’…πŸ‘€πŸ‘€πŸ’