Base58 encoding/decoding for Bitcoin
Clone or download
Permalink
Failed to load latest commit information.
test Tape instead mocha Jan 21, 2017
.gitignore ignore coverage May 27, 2014
.travis.yml Update travis config Dec 17, 2016
CHANGELOG.md CHANGE: update for 400 Dec 19, 2016
LICENSE Create LICENSE Jun 21, 2018
README.md fix example code in README.md Jul 4, 2017
index.js index: avoid unnecessary base-x unpack Aug 31, 2015
package.json 4.0.1 May 31, 2017

README.md

bs58

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 bs58

API

encode(input)

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

example:

const bs58 = require('bs58')

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

decode(input)

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

example:

const bs58 = require('bs58')

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

Hack / Test

Uses JavaScript standard style. Read more:

js-standard-style

Credits

License

MIT