Socket
Socket
Sign inDemoInstall

bs58

Package Overview
Dependencies
1
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bs58

Base 58 encoding / decoding


Version published
Weekly downloads
1.1M
decreased by-16.94%
Maintainers
6
Install size
16.9 kB
Created
Weekly downloads
 

Package description

What is bs58?

The bs58 npm package is a utility for encoding and decoding data in Base58, which is a binary-to-text encoding scheme. It is commonly used in cryptocurrency applications, particularly Bitcoin, for encoding addresses and other data in a compact, human-readable format.

What are bs58's main functionalities?

Encoding a Buffer to Base58

This feature allows you to encode a buffer of binary data into a Base58 string. The code sample demonstrates encoding the UTF-8 string 'Hello World' into Base58.

"use strict"; const bs58 = require('bs58'); const bytes = Buffer.from('Hello World', 'utf8'); const encoded = bs58.encode(bytes); console.log(encoded);

Decoding a Base58 String to a Buffer

This feature allows you to decode a Base58 string back into its original binary form, represented as a Buffer. The code sample demonstrates decoding a Base58 string back into the original UTF-8 string.

"use strict"; const bs58 = require('bs58'); const encoded = 'JxF12TrwUP45BMd'; const bytes = bs58.decode(encoded); console.log(bytes.toString('utf8'));

Other packages similar to bs58

Readme

Source

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 Uint8Array, Buffer, or an Array. It returns a string.

example:

const bs58 = require('bs58')

const bytes = Uint8Array.from([
    0, 60,  23, 110, 101, 155, 234,
   15, 41, 163, 233, 191, 120, 128,
  193, 18, 177, 179,  27,  77, 200,
   38, 38, 129, 135
])
const address = bs58.encode(bytes)
console.log(address)
// => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS

decode(input)

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

example:

const bs58 = require('bs58')

const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS'
const bytes = bs58.decode(address)
// See uint8array-tools package for helpful hex encoding/decoding/compare tools
console.log(Buffer.from(bytes).toString('hex'))
// => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187

Browser

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

npm install -g browserify

then run:

browserify node_modules/bs58/index.js -o bs58.bundle.js --standalone bs58

Hack / Test

Uses JavaScript standard style. Read more:

js-standard-style

Credits

License

MIT

Keywords

FAQs

Last updated on 17 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc