您当前的位置: 首页 >  node.js

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

彭世瑜 发布时间:2022-09-14 13:51:19 ,浏览量:1

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"

文档

  • https://www.npmjs.com/package/base62

安装

npm install base62

示例

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

console.log(base62.decode("g7"));
// 999
关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0727s