edgaras / custombase64
A PHP package for customizable Base64 encoding and decoding with support for custom character sets and optional reversed output.
Installs: 138
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/edgaras/custombase64
Requires
- php: >=8.0.0
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-09-25 06:29:46 UTC
README
A PHP package for customizable Base64 encoding and decoding with support for custom character sets and optional reversed output.
Features
- Customizable Base64 character sets.
- Optional reversed output for encoding/decoding.
Requirements
PHP 8+
Installation
- Use the library via Composer:
composer require edgaras/custombase64
- Include the Composer autoloader:
require __DIR__ . '/vendor/autoload.php';
Usage
1. Initialization
You can initialize the CustomBase64
class with optional parameters:
use Edgaras\CustomBase64\CustomBase64; // Default initialization $base64 = new CustomBase64(); // Custom charset and reversed output $customChars = 'TPUQVRWXSYZABCDENOFGHIJKLMnopqrstuvwxyzabcdefghijklm0123456789+-'; $reverseOutput = true; $base64 = new CustomBase64($customChars, $reverseOutput);
2. Encoding data
Use the encode
method to convert data into custom Base64 format:
$data = "Hello, CustomBase64!"; $encoded = $base64->encode($data); echo "Encoded: " . $encoded; // Example output: "=VUC2H2puYHoiO3p1CVSf8WofIWF"
3. Decoding Data
Decode Base64-encoded strings back to their original form using the decode
method:
$encoded = "=VUC2H2puYHoiO3p1CVSf8WofIWF"; $decoded = $base64->decode($encoded); echo "Decoded: " . $decoded; // Example output: "Hello, CustomBase64!"