Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

bstring

Package Overview
Dependencies
3
Maintainers
1
Versions
19
Issues
File Explorer

Advanced tools

bstring

String encodings for javascript

    0.3.9latest
    GitHub

Version published
Maintainers
1
Weekly downloads
938
decreased by-19.42%

Weekly downloads

Readme

Source

bstring

String encodings for javascript.

Usage

'use strict'; const assert = require('assert'); const {base58, bech32, cashaddr} = require('bstring'); // Base58 const b58 = base58.encode(Buffer.from([1,2,3])); assert(base58.test(b58)); const data = base58.decode(b58); console.log(data); // Bech32 const b32 = bech32.encode('bc', 0, Buffer.alloc(20, 0x10)); assert(bech32.test(b32)); const {hrp, version, hash} = bech32.decode(b32); console.log([hrp, version, hash]); // CashAddr const address = cashaddr.encode('bitcoincash', 0, Buffer.alloc(20, 0x10)); assert(cashaddr.test(address)); const res1 = cashaddr.decode(address); console.log([res1.prefix, res1.type, res1.hash]); const noPrefixAddress = address.split(':')[1]; assert(cashaddr.test(noPrefixAddress, 'bitcoincash')); const res2 = cashaddr.decode(noPrefixAddress, 'bitcoincash'); console.log([res2.prefix, res2.type, res2.hash]);

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. </legalese>

License

  • Copyright (c) 2017, Christopher Jeffrey (MIT License).

See LICENSE for more info.

Keywords

FAQs

Last updated on 03 May 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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