BaseConverter is a simple and small library to convert interger values to different other bases and back.
Just run the following command in your project root:
composer require neoblack/base-converter:~1.0
<?php
require_once 'vendor/autoload.php';
use NeoBlack\BaseConverter\BaseConverter;
$number = 100;
$base64Number = BaseConverter::toBase($number, BaseConverter::BASE64); // Result: 1A
$base62Number = BaseConverter::toBase($number, BaseConverter::BASE62); // Result: 1C
$base32Number = BaseConverter::toBase($number, BaseConverter::BASE32); // Result: 34
$base16Number = BaseConverter::toBase($number, BaseConverter::BASE16); // Result: 64
BaseConverter::to10Base($base64Number, BaseConverter::BASE64); // Result: 100
BaseConverter::to10Base($base62Number, BaseConverter::BASE62); // Result: 100
BaseConverter::to10Base($base32Number, BaseConverter::BASE32); // Result: 100
BaseConverter::to10Base($base16Number, BaseConverter::BASE16); // Result: 100
If you want to contribute, fork this repository and send a pull request.
./bin/phpunit -c Build/UnitTests.xml
rm -rf docs
./bin/phpunit -c Build/UnitTests.xml --coverage-html docs
The MIT License (MIT) see license file.