# bstring

> String encodings for javascript

Latest version **0.3.9** (published 2019-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install bstring
pnpm add bstring
yarn add bstring
bun add bstring
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.9 |
| Published | 2019-05-03 |
| First published | 2017-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 3 |
| Unpacked size | 70.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 3 |
| Author | Christopher Jeffrey |
| Maintainers | chjj |
| Keywords | string, base58, bech32, cashaddr |

## Links

- npm: https://www.npmjs.com/package/bstring
- Repository: https://github.com/bcoin-org/bstring
- Issues: https://github.com/bcoin-org/bstring/issues
- npm.io page: https://npm.io/package/bstring

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ^2.13.1
- [bsert](https://npm.io/package/bsert.md) ~0.0.10
- [loady](https://npm.io/package/loady.md) ~0.0.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.3.9 (latest) — 2019-05-03
- 0.3.8 — 2019-04-01
- 0.3.7 — 2019-03-21
- 0.3.6 — 2019-03-21
- 0.3.5 — 2019-01-22
- 0.3.4 — 2018-11-29
- 0.3.3 — 2018-11-28
- 0.3.2 — 2018-11-02
- 0.0.3 — 2018-11-02
- 0.1.2 — 2018-11-02
- 0.2.1 — 2018-11-02
- 0.3.1 — 2018-11-02
- 0.3.0 — 2018-09-29
- 0.2.0 — 2018-08-10
- 0.1.1 — 2018-07-19
- … 4 more at https://npm.io/package/bstring/versions

## README

# bstring

String encodings for javascript.

## Usage

``` js
'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.

---
_Source: https://npm.io/package/bstring · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
