# @digitalcredentials/base58-universal 中文文档

规范地址：https://npmcn.com/package/%40digitalcredentials/base58-universal/

版本：1\.0\.1
npm 元数据更新时间：2026-09-30T17:44:32.918Z
中文译文更新时间：2026-11-12T08:52:20.015Z
软件包许可：BSD-3-Clause

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40digitalcredentials/base58-universal
原文对照：https://npmcn.com/package/%40digitalcredentials/base58-universal/?lang=original
项目主页：https://github.com/digitalcredentials/base58-universal
源码仓库：https://github.com/digitalcredentials/base58-universal

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：20.8 kB，12 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- Node.js 要求：\>=12
- 运行依赖：0 个
- 首次发布：2021-05-19T18:25:20.408Z
- 最新版本发布：2021-09-17T18:33:32.990Z
- 近 30 天下载量：23105（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 0 个）

## 中文简介

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

## 安装

```sh
npm install @digitalcredentials/base58-universal
```

也可以使用：`pnpm add @digitalcredentials/base58-universal`、`yarn add @digitalcredentials/base58-universal`、`bun add @digitalcredentials/base58-universal`

## README

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

> 编码器/编码器 [Base58编码方案](https://github.com/digitalbazaar/base58-spec) 页:1 [节点.js](https://nodejs.org/) 和 Web 浏览器

## 目录

-   [警卫](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-security)
-   [背景情况](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-background)
-   [安装](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-install)
-   [使用量](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-usage)
-   [贡献](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-contribute)
-   [商业支助](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-commercial-support)
-   [许可证](https://npmcn.com/package/%40digitalcredentials/base58-universal/#readme-license)

## 警卫

传统发展

## 背景情况

(从 [`digitalbazaar/base58-universal`](https://github.com/digitalbazaar/base58-universal) 以提供类型脚本兼容性。 )

此库为 [Base58编码方案](https://github.com/digitalbazaar/base58-spec) 使用比特币流行的字母表. 两者都有用 [节点.js](https://nodejs.org/) 内 没有依赖关系的 Web 浏览器 .

## 安装

-   需要8.3+节点.

要安装用于 [节点.js](https://nodejs.org/) 使用 npm 的网络项目 :

```
npm install @digitalcredentials/base58-universal
```

在当地安装或用于开发:

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

## 使用量

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

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

```js
import {encode, decode} from '@digitalcredentials/base58-universal';
```

### 编码

-   `encode(input[, maxline])`
    -   **`input`**数字 : `Uint8Array` - 要编码的字节
    -   **`maxline`**数字 : `Number` - 每行的最大编码字符数 使用,默认为无限.
    -   返回一个已编码的 Base58 字符串.

```js
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` 与已解码的字节.

```js
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 阵列](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) 用于编码器输入和解码器输出. 从字符串转换可以使用各种工具来完成.

#### 浏览器

-   [文本编码器](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) 财务报告和审定财务报表 [文本解析器](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) 使用 [编码](https://encoding.spec.whatwg.org/) 标准.

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

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

#### 节点.js

-   [ut. 文本编码器](https://nodejs.org/api/util.html#util_class_util_textencoder) 财务报告和审定财务报表 [ut. 文本解析器](https://nodejs.org/api/util.html#util_class_util_textdecoder) 使用 [编码](https://encoding.spec.whatwg.org/) 标准.
-   [缓冲](https://nodejs.org/api/buffer.html) `from` 财务报告和审定财务报表 `toString` 带有编码选项.

```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
```

## 贡献

请跟随 [贝德洛克贡献 准则](https://github.com/digitalbazaar/bedrock/blob/master/CONTRIBUTING.md)。 。 。 .

公关接受.

如果编辑 README, 请遵守 [标准读取](https://github.com/RichardLitt/standard-readme) 规格.

## 商业支助

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

## 许可证

[新建 BSD 许可证( 3- clause)](https://npmcn.com/package/%40digitalcredentials/base58-universal/LICENSE) 数字集市

编码器/解码器原执行来源 [碱-x](https://github.com/cryptocoinjs/base-x) 根据麻省理工学院的许可.

## 常见问题

### @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 和提交记录判断。

