1.0.0 • Published 3 years ago

@relocke/base58 v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

@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

ParameterTypeDescription
base58Stringbase58_charsbase58 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

ParameterTypeDescription
uint8arrayUint8Array | Arrayunsigned 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