Node.js:base62实现长数字压缩为短字符串
【摘要】
Base62 encoding converts numbers to ASCII strings (0-9, a-z and A-Z) and vice versa, which typically r...
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"
- 1
- 2
- 3
文档
安装
npm install base62
- 1
示例
const base62 = require("base62/lib/ascii");
console.log(base62.encode(999));
// g7
console.log(base62.decode("g7"));
// 999
- 1
- 2
- 3
- 4
- 5
- 6
- 7
文章来源: pengshiyu.blog.csdn.net,作者:彭世瑜,版权归原作者所有,如需转载,请联系作者。
原文链接:pengshiyu.blog.csdn.net/article/details/126851134
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)