Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@web3pack/base-x

Web3Pack14.8kMIT1.0.2TypeScript support: included

A modern base-x encoding library implemented in TypeScript with minimal dependencies for use in browser and Node.js.

base2, base16, base45, base58, encode, encoding, decode, decoding, crypto, crytography

readme

CodeQL Node.js Package

Base-x encoding library

A modern base-x encoding library implemented in TypeScript with minimal dependencies for use in browser and Node.js.

Following alphabets are supported:

  • Base2 = 01
  • Base16 = 0123456789abcdef
  • Base45 = 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:
  • Base58 = 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

Example

import { base58 } from '../src';

const base58Converter = base58();

const text = Buffer.from('Hello World!');

const base58Text = base58Converter.encode(text);
// => 2NEpo7TZRRrLZSi2U

const base58Decoded = base58Converter.decode(base58Text);
const base58DecodedText = Buffer.from(base58Decoded).toString();
// => Hello World!