Ascii85 (Base85) Encode and Decode using PHP

tuupola/base85 library

  1. Add tuupola/base85 library to composer.json file:
"require": {
    "tuupola/base85": "^2.0"
}
  1. Install library from the command line:
composer install
  1. Encode and decode data using Ascii85 (Base85):
<?php

use Tuupola\Base85;

require_once __DIR__.'/vendor/autoload.php';

$ascii85 = new Base85([
    'characters' => Base85::ASCII85,
    'compress.spaces' => false,
    'compress.zeroes' => true,
]);

$text = 'Hello';
$ascii85Str = $ascii85->encode($text);
echo $ascii85Str.PHP_EOL;

$text = $ascii85->decode($ascii85Str);
echo $text.PHP_EOL;

Leave a Comment

Cancel reply

Your email address will not be published.