Download the PHP package codepower/anybase without Composer
On this page you can find all versions of the php package codepower/anybase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codepower/anybase
More information about codepower/anybase
Files in codepower/anybase
Package anybase
Short Description Convert integers between arbitrary bases with custom alphabets, salt, padding, and big-integer support.
License MIT
Homepage https://github.com/codepower-tw/anybase-php
Informations about the package anybase
anybase-php
Convert non-negative integers (including DB-primary-key big integers) between arbitrary numeric bases using custom alphabets. For URL-friendly ID obfuscation, short codes, and human-readable hashing — not for cryptographic security.
Install
composer require codepower/anybase
PHP 8.1+. Optional: ext-gmp (preferred) or ext-bcmath for integers larger
than PHP_INT_MAX.
Quick start
Custom alphabet
Salt (per-environment scrambling)
XOR the integer with a fixed salt so that staging IDs and prod IDs don't visually overlap. This is not encryption — anyone with one plaintext- ciphertext pair can recover the salt.
Padding
Convert between bases
Predefined alphabets
base2 base8 base10 base16 base16Upper base32Rfc4648 base32Hex
crockfordBase32 base36 base58Bitcoin base58Flickr base62
base64Url supercellHashtag
Crockford base32 folds I/L → 1 and O → 0 on decode and is case-insensitive.
Supercell hashtag folds I/1 → L, O → 0, B → 8 on decode and is
case-insensitive by default. Both behaviors are configurable:
Big integers
For values larger than PHP_INT_MAX (2^63 − 1), install ext-gmp (preferred)
or ext-bcmath. The library auto-selects:
- Native PHP int when the value fits.
- GMP when available.
- BCMath as fallback.
Pin a specific backend with ->withBackend(new \Anybase\Backend\NativeBackend()).
Errors
All exceptions implement \Anybase\Exception\AnybaseException. Specific
classes: InvalidAlphabetException, InvalidInputException,
OverflowException, MissingExtensionException.
Testing
This package uses Pest 2:
composer test
License
MIT.