Stars: 127
Forks: 28
Pull Requests: 24
Issues: 10
Watchers: 7
Last Updated: 2022-05-12 10:51:32
Base32 Encoder/Decoder according to RFC 4648
License: MIT License
Languages: PHP
Base32 Encoder/Decoder for PHP according to RFC 4648.
Use composer:
composer require christian-riesen/base32
<?php
// Include class or user autoloader
use Base32\Base32;
$string = 'fooba';
// $encoded contains now 'MZXW6YTB'
$encoded = Base32::encode($string);
// $decoded is again 'fooba'
$decoded = Base32::decode($encoded);
You can also use the extended hex alphabet by using the Base32Hex
class instead.
Initially created to work with the one time password project, yet it can stand alone just as well as Jordi Boggiano kindly pointed out. It's the only Base32 implementation that passes the test vectors and contains unit tests as well.
Have a RFC compliant Base32 encoder and decoder. The implementation could be improved, but for now, it does the job and has unit tests. Ideally, the class can be enhanced while the unit tests keep passing.
Works on PHP 7.2 and later, including PHP 8.0.
Tests run on PHPUnit 9.5, with PHP 7.3 and later. For PHP 7.2, tests use an older PHPUnit version.
Christian Riesen [email protected] https://christianriesen.com
Base32 is mostly based on the work of https://github.com/NTICompass/PHP-Base32