Base62 encoding converts numbers to ASCII strings (0-9, a-z and A-Z) and vice versa, which typically results in comparatively short strings. Such identifiers also tend to more readily identifiable by humans.

译文:Base62编码将数字转换为ASCII字符串(0-9、a-z和a-z),反之亦然,这通常会导致相对较短的字符串。这种标识符也往往更容易被人类识别。

例如:

999 => "g7"
9999 => "2Bh"
238327 => "ZZZ"

文档

安装

npm install

示例

const base62 = require("base62/lib/ascii");

console.log(base62.encode(999));
// g7

console.log(base62.decode("g7"));
// 999