JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 580
  • Score
    100M100P100Q97000F
  • License MIT

Base 58 encoding / decoding

Package Exports

  • b58

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (b58) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

b58

build status

JavaScript component to compute base 58 encoding. This encoding is typically used for crypto currencies such as Bitcoin.

Note: If you're looking for base 58 check encoding, see: https://github.com/bitcoinjs/bs58check, which depends upon this library.

Install

npm i --save b58

API

encode(input)

input must be a Buffer or an Array. It returns a string.

example:

const b58 = require('b58')

const bytes = Buffer.from('003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187', 'hex')
const address = b58.encode(bytes)
console.log(address)
// => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS

decode(input)

input must be a base 58 encoded string. Returns a Buffer.

example:

const b58 = require('b58')

const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS'
const bytes = b58.decode(address)
console.log(bytes.toString('hex'))
// => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187

Hack / Test

Uses JavaScript standard style. Read more:

js-standard-style

Credits

License

MIT