RFC 4648 Base32 groups bytes into five-bit values represented by A-Z and 2-7, then pads the final eight-character block with =. This decoder ignores whitespace and letter case but validates block length, padding, and unused padding bits.
Use Base32 for human-entered tokens or systems that prefer a case-insensitive alphanumeric alphabet. It expands data by about 60%, supplies neither secrecy nor error detection, and is not compatible with Crockford Base32 or Base32hex alphabets.
// npm install hi-base32
const base32 = require('hi-base32');
const encoded = base32.encode('Hello');
console.log(encoded);
// Output: JBSWY3DP
const decoded = Buffer.from(base32.decode.asBytes('JBSWY3DP')).toString('utf8');
console.log(decoded);
// Output: Hello
package main
import (
"encoding/base32"
"fmt"
)
func main() {
encoded := base32.StdEncoding.EncodeToString([]byte("Hello"))
fmt.Println(encoded)
// Output: JBSWY3DP
decoded, _ := base32.StdEncoding.DecodeString("JBSWY3DP")
fmt.Println(string(decoded))
// Output: Hello
}
<?php
// composer require paragonie/constant_time_encoding
require 'vendor/autoload.php';
use ParagonIE\ConstantTime\Encoding;
$encoded = Encoding::base32EncodeUpper("Hello");
echo $encoded . "\n";
// Output: JBSWY3DP
$decoded = Encoding::base32DecodeUpper("JBSWY3DP");
echo $decoded . "\n";
// Output: Hello