@darkwolf/base58.cjs
v1.0.1
Published
Base58
Downloads
22
Maintainers
Readme
Base58
Install
ECMAScript (Node.js v12.x LTS or higher)
npm i --save @darkwolf/base58.mjs
CommonJS (Node.js v10.x LTS or higher)
npm i --save @darkwolf/base58.cjs
Using
// ECMAScript
import Base58, { Alphabet } from '@darkwolf/base58.mjs'
// CommonJS
const Base58 = require('@darkwolf/base58.cjs')
const { Alphabet } = Base58
const encoded = Base58.encode('Ave, Darkwolf!') // 'HDmiyDYm3PDiZ4kmjkb'
Base58.decode(encoded) // 'Ave, Darkwolf!'
const encodedInteger = Base58.encodeInteger(10000) // 'eyH'
Base58.decodeInteger(encodedInteger) // 10000
// Custom alphabet
const base58 = new Base58(Alphabet.BITCOIN)
const encodedBtc = base58.encode('Ave, Darkwolf!') // 'R4qoy4gqDX4ohE7qp7i'
base58.decode(encodedBtc) // 'Ave, Darkwolf!'
const encodedBtcInteger = base58.encodeInteger(10000) // '3yR'
base58.decodeInteger(encodedBtcInteger) // 10000