allty/base58

用PHP编写的Base58编码器/解码器。

dev-master 2014-04-28 13:01 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:28:44 UTC


README

使用base-58编码缩短URL

此类可用于将整数(十进制)转换为base-58字符串。Base-58包含字母数字字符,但不包括“l”(字母l)、“0”(数字0)和“O”(字母O),以防止误输入。

使用composer安装Base58

{
    "require" : "allty/base58"
}

用法

use Allty\Utils\Base58;

// We will usually use something like a auto-incremented key from MySQL
$url_id = 627868726;

// encode() (shorten)
$short = Base58::encode($url_id); // "XtZuS"

// decode()
$decoded = Base58::decode($short); // 627868726