Lenny4 / compress-int

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compress integer into alphanumeric

Installation

You can install the package via composer:

composer require lenny4/compress-int

Usage

$number = 123456;
$compress = Lenny4\CompressInt::compress($number); // e7w
$decompress = Lenny4\CompressInt::decompress($compress); // 123456

You can change symbols use for compress and decompress:

$number = 123456;
$customSymbols = '0123456789abcdefghijklmnopqrstuvwxyz'
$compress = Lenny4\CompressInt::compress($number, $customSymbols);
$decompress = Lenny4\CompressInt::decompress($compress, $customSymbols);

Symbols:

Lenny4\CompressInt::DEFAULT_SYMBOLS // 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Lenny4\CompressInt::LONG_SYMBOLS // 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&()*+,-/:;<=>?@[\]^_{|}~
Lenny4\CompressInt::DEFAULT_SYMBOLS_INSENSITIVE // 0123456789abcdefghijklmnopqrstuvwxyz
Lenny4\CompressInt::LONG_SYMBOLS_INSENSITIVE // 0123456789abcdefghijklmnopqrstuvwxyz!#$%&()*+,-/:;<=>?@[\]^_{|}~

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

About

License:MIT License


Languages

Language:PHP 100.0%