@digitalcredentials/base58-universal

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

Encode/decode using the Base58 Bitcoin Encoding Scheme.

原始使用文档
文档目录11 节
  1. Table of Contents
  2. Security
  3. Background
  4. Install
  5. Usage
  6. Encoding
  7. Decoding
  8. String Handling
  9. Contribute
  10. Commercial Support
  11. License

Base58 Universal Encoder/Decoder (@digitalcredentials/base58-universal)

Encoder/decoder for The Base58 Encoding Scheme for Node.js and Web browsers

Table of Contents

Security

TBD

Background

(Forked from digitalbazaar/base58-universal to provide TypeScript compatibility.)

This library provides an encoder and decoder for The Base58 Encoding Scheme using an alphabet popularized by Bitcoin. It works in both Node.js and in Web browsers with no dependencies.

Install

  • Node.js 8.3+ required.

To install for Node.js or in a Web project using npm:

npm install @digitalcredentials/base58-universal

To install locally or for development:

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

Usage

The library can be loaded with CommonJS or ESM:

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

Encoding

  • encode(input[, maxline])
    • input: Uint8Array - bytes to encode
    • maxline: Number - maximum number of encoded characters per line to use, defaults to infinite.
    • Returns a base58 encoded string.
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

Decoding

  • decode(input)
    • input: String - string to decode
    • Returns a Uint8Array with the decoded bytes.
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
// ]

String Handling

This library uses Uint8Array for encoder input and decoder output. Conversion to and from strings can be done with a variety of tools.

Browser

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

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

Node.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

Contribute

Please follow the Bedrock contributing guidelines.

PRs accepted.

If editing the README, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

New BSD License (3-clause) © Digital Bazaar

Encoder/decoder original implementation from base-x under the MIT License.

版本与发布记录

@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 是什么?

Encode/decode using the Base58 Bitcoin Encoding Scheme.

如何安装 @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 和提交记录判断。