PHP code example of tuupola / base32
1. Go to this page and download the library: Download tuupola/base32 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/ */
tuupola / base32 example snippets
use Tuupola\Base32;
$base32 = new Base32([
"characters" => Base32::RFC4648,
"padding" => "="
]);
print $base32->encode("Hello world!"); /* JBSWY3DPEB3W64TMMQQQ==== */
$base32hex = new Base32([
"characters" => Base32::HEX,
"padding" => "="
]);
print $base32->encode("Hello world!"); /* 91IMOR3F41RMUSJCCGGG==== */
$gmp = new Base32([
"characters" => Base32::GMP,
"padding" => false
]);
print $gmp->encode("Hello world!"); /* 91IMOR3F41RMUSJCCGGG */
$crockford = new Base32([
"characters" => Base32::CROCKFORD,
"padding" => false,
"crockford" => true,
]);
print $crockford->encode("Hello world!"); /* 91JPRV3F41VPYWKCCGGG */
print $crockford->decode("91JPRV3F41VPYWKCCGGG"); /* Hello world! */
print $crockford->decode("91jprv3f41vpywkccggg"); /* Hello world! */
print $crockford->decode("9ljprv3f4lvpywkccggg"); /* Hello world! */
use Tuupola\Base32;
print Base32::CROCKFORD; /* 0123456789ABCDEFGHJKMNPQRSTVWXYZ */
print Base32::RFC4648; /* ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 */
print Base32::ZBASE32; /* ybndrfg8ejkmcpqxot1uwisza345h769 */
print Base32::GMP; /* 0123456789ABCDEFGHIJKLMNOPQRSTUV */
print Base32::HEX; /* 0123456789ABCDEFGHIJKLMNOPQRSTUV */
$default = new Base32(["characters" => Base32::RFC4648]);
$crockford = new Base32(["characters" => Base32::CROCKFORD]);
print $default->encode("Hello world!"); /* JBSWY3DPEB3W64TMMQQQ==== */
print $inverted->encode("Hello world!"); /* 91JPRV3F41VPYWKCCGGG==== */
php
$base32 = new Tuupola\Base32;
$encoded = $base32->encode(random_bytes(128));
$decoded = $base32->decode($encoded);
php
$integer = $base32->encodeInteger(987654321); /* 5N42FR== */
print $base32->decodeInteger("5N42FR=="); /* 987654321 */
php
$integer = $base32->encodeInteger(987654321); /* 5N42FR== */
$string = $base32->encode("987654321"); /* FHE4DONRVGQZTEMI= */
php
use Tuupola\Base32Proxy as Base32;
$encoded = Base32::encode(random_bytes(128));
$decoded = Base32::decode($encoded);