# bs58

> Base 58 encoding / decoding

Latest version **6.0.0** (published 2024-06-24) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2024-06-24 |
| First published | 2013-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 235 |
| Keywords | base58, bitcoin, crypto, crytography, decode, decoding, encode, encoding, litecoin |

## Links

- npm: https://www.npmjs.com/package/bs58
- Repository: https://github.com/cryptocoinjs/bs58
- Homepage: https://github.com/cryptocoinjs/bs58#readme
- Issues: https://github.com/cryptocoinjs/bs58/issues
- npm.io page: https://npm.io/package/bs58

## Dependencies (1)

- [base-x](https://npm.io/package/base-x.md) ^5.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 6.0.0 (latest) — 2024-06-24
- 5.0.0 — 2022-02-17
- 4.0.1 — 2017-06-01
- 4.0.0 — 2016-12-20
- 3.1.0 — 2016-12-01
- 3.0.0 — 2015-08-18
- 2.0.1 — 2014-12-23
- 2.0.0 — 2014-10-03
- 1.2.1 — 2014-07-24
- 1.2.0 — 2014-06-29
- 1.1.0 — 2014-06-26
- 1.0.0 — 2014-05-27
- 0.3.0 — 2014-02-24
- 0.2.1 — 2014-02-24
- 0.2.0 — 2013-12-08

## README

bs58
====

[![build status](https://travis-ci.org/cryptocoinjs/bs58.svg)](https://travis-ci.org/cryptocoinjs/bs58)

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](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**:

```js
import bs58 from '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**:

```js
import bs58 from '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:

```bash
npm install -g browserify
```

then run:

```bash
browserify node_modules/bs58/cjs/index.cjs -o bs58.bundle.js --standalone bs58
```

Hack / Test
-----------

Uses JavaScript standard style. Read more:

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)


Credits
-------
- [Mike Hearn](https://github.com/mikehearn) for original Java implementation
- [Stefan Thomas](https://github.com/justmoon) for porting to JavaScript
- [Stephan Pair](https://github.com/gasteve) for buffer improvements
- [Daniel Cousens](https://github.com/dcousens) for cleanup and merging improvements from bitcoinjs-lib
- [Jared Deckard](https://github.com/deckar01) for killing `bigi` as a dependency


License
-------

MIT

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