Skip to content

Change raw binary bytes to an arbitrary base e.g. 36, 58, or 64 for example

License

Notifications You must be signed in to change notification settings

DavidFricker/PHP-binary-base-changer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP binary base changer

Change raw binary bytes to and from an arbitrary base e.g. 36, 58, or 64. This package stands in place of PHP's native base_convert() function and in doing so provides support for arbitrarily large numbers.

Requirements

This package requires the GMP PHP extension to be installed.

Install

Via composer:

composer require davidfricker/basechanger

Usage

use DavidFricker\BaseChanger\GMP;

$bytes = openssl_random_pseudo_bytes(32);
$base = 64;

$base_converted = GMP::changeTo($bytes, $base);
$base_reversed = GMP::changeFrom($base_converted, $base);

Licence

This code is released under MIT. Full licence can be found in the licence file.

About

Change raw binary bytes to an arbitrary base e.g. 36, 58, or 64 for example

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages