@digitalcredentials/base58-universal

中文文档
1.0.1发布于 2021/09/18BSD-3-ClauseESM + CJS零依赖近 30 天下载 2.3万

使用 Base58 比特币编码方案的编码/解码.

中文使用文档
文档目录11 节
  1. 目录
  2. 警卫
  3. 背景情况
  4. 安装
  5. 使用量
  6. 编码
  7. 解码
  8. 字符串处理
  9. 贡献
  10. 商业支助
  11. 许可证

Base58 通用编码器/解码器 (@数字证书/基础58-普遍)

编码器/编码器 Base58编码方案 页:1 节点.js 和 Web 浏览器

目录

警卫

传统发展

背景情况

(从 digitalbazaar/base58-universal 以提供类型脚本兼容性。 )

此库为 Base58编码方案 使用比特币流行的字母表. 两者都有用 节点.js 内 没有依赖关系的 Web 浏览器 .

安装

  • 需要8.3+节点.

要安装用于 节点.js 使用 npm 的网络项目 :

npm install @digitalcredentials/base58-universal

在当地安装或用于开发:

git clone https://github.com/digitalcredentials/base58-universal.git
cd base58-universal
npm install

使用量

库可装入普通JS或无害环境管理:

const {encode, decode} = require('@digitalcredentials/base58-universal');
import {encode, decode} from '@digitalcredentials/base58-universal';

编码

  • encode(input[, maxline])
    • input数字 : Uint8Array - 要编码的字节
    • maxline数字 : Number - 每行的最大编码字符数 使用,默认为无限.
    • 返回一个已编码的 Base58 字符串.
import {encode} from 'base58-universal';

const input1 = Uint8Array([1, 2, 3, 4]);
const encoded1 = encode(input1);
// > 2VfUX

const input2 = Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const encoded2 = encode(input2, 8);
// > 4HUtbHhN\r\n2TkpR

解码

  • decode(input)
    • input数字 : String - 要解码的字符串
    • 回返a Uint8Array 与已解码的字节.
import {decode} from 'base58-universal';

const input3 = '2VfUX';
const decoded3 = decode(input3);
// > Uint8Array [ 1, 2, 3, 4 ]

const input4 = '4HUtbHhN\r\n2TkpR';
const decoded4 = decode(input4);
// > Uint8Array [
//   1, 2, 3, 4,  5,
//   6, 7, 8, 9, 10
// ]

字符串处理

此库使用 Uint8 阵列 用于编码器输入和解码器输出. 从字符串转换可以使用各种工具来完成.

浏览器

const input5 = new TextEncoder().encode('abc');
const encoded5 = encode(input5);
// > ZiCa

const decoded6 = decode(encoded5);
const output6 = new TextDecoder().decode(decoded6);
// > abc

节点.js

// Using TextEncoder/TextDecoder
const {TextEncoder, TextDecoder} = require('util');

const input7 = new TextEncoder().encode('abc');
const encoded7 = encode(input7);
// > ZiCa

const decoded8 = decode(encoded7);
const output8 = new TextDecoder().decode(decoded8);
// > abc

// Using Buffer (which is a Uint8Array)
const input9 = Buffer.from('616263', 'hex');
const encoded9 = encode(input9);
const decoded9 = decode(encoded9);
Buffer.from(decoded9).toString();
// > abc
Buffer.from(decoded9).toString('hex');
// > 616263

贡献

请跟随 贝德洛克贡献 准则。 。 。 .

公关接受.

如果编辑 README, 请遵守 标准读取 规格.

商业支助

该图书馆的商务支助可应下列请求提供: 数字集市: 支持@ digitalbazaar.com

许可证

新建 BSD 许可证( 3- clause) 数字集市

编码器/解码器原执行来源 碱-x 根据麻省理工学院的许可.

版本与发布记录

@digitalcredentials/base58-universal 共发布 2 个版本,首次发布于 2021/05/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2021/09/185 年前
1.0.02021/05/205 年前

关于 @digitalcredentials/base58-universal 的常见问题

@digitalcredentials/base58-universal 是什么?

使用 Base58 比特币编码方案的编码/解码.

如何安装 @digitalcredentials/base58-universal?

在项目目录运行 npm install @digitalcredentials/base58-universal,或使用 pnpm add / yarn add / bun add。

@digitalcredentials/base58-universal 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/digitalcredentials__base58-universal 是否存在。

@digitalcredentials/base58-universal 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@digitalcredentials/base58-universal 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@digitalcredentials/base58-universal 可以商用吗?

@digitalcredentials/base58-universal 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@digitalcredentials/base58-universal 的下载量有多少?

根据 npm 官方下载统计,@digitalcredentials/base58-universal 在 2026/10/12 – 2026/11/10 这 30 天内被下载 23,105 次,日均约 770 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@digitalcredentials/base58-universal 还在维护吗?

最新版本 1.0.1 发布于 2021/09/18(5 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/05/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。