brianfreytag / php-bijective
将任何整数编码为基(n)字符串
v1.0.1
2014-11-19 17:22 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: >=3.7
This package is auto-updated.
Last update: 2024-09-09 07:50:50 UTC
README
使用定义的字母表将任何整数编码为基(n)字符串。
安装
建议的安装方法是使用 composer
php composer.phar require brianfreytag/php-bijective:dev-master
使用方法
安装 Bijective 库后,只需创建一个 Bijective 类的新实例,并传入定义的字母表。
<?php use Bijective\BijectiveTranslator; $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $bijective = new BijectiveTranslator($alphabet); $encoded = $bijective->encode(123); // Returns ct $decoded = $bijective->decode('ct'); // Returns 123