ripple-bs58

4.0.1 • Public • Published

ripple-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/ripple-bs58check, which depends upon this library.

Install

npm i --save ripple-bs58

API

encode(input)

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

example:

const bs58 = require('ripple-bs58')
 
const bytes = Buffer.from('003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187', 'hex')
const address = bs58.encode(bytes)
console.log(address)
// => ra7jcY4BG9GTKhuqpCfyYNbu5CqUzoLMGS

decode(input)

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

example:

const bs58 = require('ripple-bs58')
 
const address = 'ra7jcY4BG9GTKhuqpCfyYNbu5CqUzoLMGS'
const bytes = new Buffer(bs58.decode(address))
console.log(bytes.toString('hex'))
// => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187

Hack / Test

Uses JavaScript standard style. Read more:

js-standard-style

Credits

License

MIT

Dependencies (1)

Dev Dependencies (2)

Package Sidebar

Install

npm i ripple-bs58

Weekly Downloads

3,381

Version

4.0.1

License

MIT

Last publish

Collaborators

  • you21979