lenny4/compress-int

Compress integer into alphanumeric

v1.1.0 2021-11-19 19:49 UTC

This package is auto-updated.

Last update: 2024-10-20 02:06:05 UTC


README

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.