gb64

A high-performance, pure Perl implementation of Base64 encoding and decoding, compliant with RFC 4648.

Synopsis

use gb64 qw(enc_b64 dec_b64);

# Direct encoding/decoding
my $encoded = enc_b64("Hello World");  # Returns "SGVsbG8gV29ybGQ="
my $decoded = dec_b64($encoded);       # Returns "Hello World"

# Streaming encoding/decoding

my $gb64 = gb64->new;
$gb64->add("Hello ")->add("World");
$encoded = $gb64->encode;              # Returns "SGVsbG8gV29ybGQ="

Description

gb64 is a fast and lightweight Base64 encoding and decoding library in pure Perl, with no XS or C dependencies. It supports both one-shot encoding/decoding and streaming for large or incremental datasets. Optimized with unpack, pack, and array-based lookups, gb64 outperforms other pure Perl implementations like MIME::Base64::Perl by up to 97.7% for large inputs (110k bytes). The module is compliant with RFC 4648, includes robust error handling, and is compatible with Perl 5.8.8 and later.

Features

Installation

To install from CPAN:

cpan gb64

Or manually:

perl Makefile.PL
make
make test
make install

Dependencies

Testing

Run the test suite to verify functionality:

prove -v ./

The test suite includes functional, streaming, and error-handling tests, using MIME::Base64 as a reference implementation.

Performance

Benchmarks show gb64 achieves:

Author

OnEhIppY, Domero Software domerosoftware@gmail.com (mailto:domerosoftware@gmail.com)

Copyright and License

Copyright (C) 2025 by OnEhIppY, Domero Software This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either:

Support

See Also