@ReLocke/base58
A ultra light weight stand alone JS implementation for base58 encoding & decoding.
- zero dependencies 🙅
- Only ~500 Bytes 🤏
size guaranteed with size-limit
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
- 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)
Buffer.from(bin).toString('hex')
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)