lenny4 / compress-int
Compress integer into alphanumeric
Installs: 1 356
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.20
- spatie/ray: ^1.28
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.