amirax / base62
Base62 encoder and decoder
Installs: 111
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/amirax/base62
Requires
- php: ^5.6 || ^7.0
Requires (Dev)
- paragonie/random_compat: ^2.0
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
This package is not auto-updated.
Last update: 2025-10-12 07:31:08 UTC
README
Install
The preferred way to install this extension is through composer.
Either run:
composer require amirax/base62
Usage
This package use encoder based on pure PHP. Library can encode strings, integers or bytes.
use Amirax\Base62; $base62 = new Base62(); echo $encodedData = $base62->encode('Hello World!'); // T8dgcjRGkZ3aysdN echo $base62->decode($encodedData); // Hello World!
Also you can use a salt:
use Amirax\Base62; echo (new Base62())->encode('Hello World!'); // T8dgcjRGkZ3aysdN echo (new Base62('my_secret_salt'))->encode('Hello World!'); // e4NKCYHiEbv8qjNx
Or you can set custom alphabet:
use Amirax\Base62; // Custom alphabet without salt. Output: 2678lx5gvmsv1dro9b5 echo (new Base62('', '0123456789abcdefghijklmnopqrstuvwxyz'))->encode('Hello World!'); // ... and with salt. Output: v79ljqkhx3bxnafi2mk echo (new Base62('my_secret_salt', '0123456789abcdefghijklmnopqrstuvwxyz'))->encode('Hello World!');
Testing
You can run tests either run:
composer test
License
The MIT License (MIT). Please see License File for more information.