Base32 Encode and Decode using PHP

christian-riesen/base32 library

  1. Add christian-riesen/base32 library to composer.json file:
"require": {
    "christian-riesen/base32": "^1.5"
}
  1. Install library from the command line:
composer install
  1. Encode and decode data using Base32:
<?php

use Base32\Base32;

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

$text = 'Hello';
$base32Str = Base32::encode($text);
echo $base32Str.PHP_EOL;

$text = Base32::decode($base32Str);
echo $text.PHP_EOL;

Leave a Comment

Cancel reply

Your email address will not be published.