bs58

build status Coverage Status Version

JavaScript component to compute base 58 encoding. This encoding is typically used for crypto currencies such as Bitcoin. See this article for more details: bitcoin address.

Package Info

Usage

Installation

npm install --save bs58

browser

You can use this module in the browser. Install Browserify:

npm install -g browserify

then run:

browserify < lib/bs58.js > lib/bs85.bundle.js

API

encode(input)

input must be a Buffer. It returns a string.

example:

var base58 = require('bs58');

var unencodedData = "003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187"; 

var out = base58.encode(new Buffer(unencodedData, 'hex'));
console.log(out); // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS

decode(input)

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

example:

var base58 = require('base58');

var address = "16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS";
var out = base58.decode(address)
console.log(out.toString('hex')); // => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187