Node.js:base62实现长数字压缩为短字符串

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 base62

示例

const base62 = require("base62/lib/ascii");
 
console.log(base62.encode(999));
// g7

console.log(base62.decode("g7"));
// 999
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值