@relocke/base58

v1.0.0
A ultra light weight (566 byte) base58 encode / decode
base58 decode encode bitcoin blockchain

@ReLocke/base58

A ultra light weight stand alone JS implementation for base58 encoding & decoding.

  • zero dependencies 🙅
  • Only ~500 Bytes 🤏

size guaranteed with size-limit

npm version

support

setup

npm i --save @relocke/base58

esm import

import { base58_to_binary, binary_to_base58 } from '@relocke/base58'
import base58_to_binary from '@relocke/base58/base58_to_binary.js'

cjs require

const {
  base58_to_binary,
  binary_to_base58
} = require('@relocke/base58/base58_to_binary.js')
const base58_to_binary = require('@relocke/base58/base58_to_binary.js')

Reference

  1. IETF

API

Table of contents

namespace base58_chars

Base58 characters must ONLY include 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

Type: string


function base58_to_binary

converts a base58 to its corresponding binary representation Uint8Array

Parameter Type Description
base58String base58_chars base58 encoded string

Returns: Uint8Array — binary representation for the base58 string

Examples

base58 to binary

import { base58_to_binary } from '@relocke/base58'

const bin = base58_to_binary("6MRy")
console.log(bin) // Uint8Array(3) [15, 239, 64]
Buffer.from(bin).toString('hex') // 0fef40

function binary_to_base58

Converts a Uint8Array into a base58 string

Parameter Type Description
uint8array Uint8Array | Array unsigned integer array

Returns: base58_chars — base58 string representation from the binary array

Examples

Binary array to base58 string

import { binary_to_base58 } from '@relocke/base58'

const str = binary_to_base58([15, 239, 64])
console.log(str) // 6MRy
npm i @relocke/base58

Metadata

  • MIT
  • >= 8
  • ReLocke
  • released 12/11/2020

Downloads

Maintainers