Base32 encoder/decoder according to RFC 4648

1.3.2 2018-11-02 09:03 UTC

This package is auto-updated.

Last update: 2020-10-23 19:55:27 UTC


Base32 Encoder/Decoder for PHP according to RFC 4648.

Build Status HHVM Status

Latest Stable Version Total Downloads Latest Unstable Version License

Do you like this? Flattr it:

Flattr base32



// Include class or user autoloader
use Base32\Base32;

$string = 'fooba';

$encoded = Base32::encode($string);
// $encoded contains now 'MZXW6YTB'

$decoded = Base32::decode($encoded);
// $decoded is again 'fooba'



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 I could make work that passes the test vectors (and contains unit tests).


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.


PHP 5.3 to 5.6 or 7.0+

If you want to run the tests, PHPUnit 5.0+ or up is required. Tests require PHP 5.6 or 7.0+.


Christian Riesen


Base32 is mostly based on the work of