# nano-base32

> A small, quick, self-contained implementation of the Base32 encoding/decoding scheme used by the cryptocurrency Nano.

Latest version **1.0.1** (published 2018-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install nano-base32
pnpm add nano-base32
yarn add nano-base32
bun add nano-base32
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-04-16 |
| First published | 2018-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gray Olson |
| Maintainers | grayolson |
| Keywords | base32 encode, base32 encoder, base32, base32hex, nano |

## Links

- npm: https://www.npmjs.com/package/nano-base32
- Repository: https://github.com/temrhn/nano-base32
- npm.io page: https://npm.io/package/nano-base32

## 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

- 1.0.1 (latest) — 2018-04-16
- 1.0.0 — 2018-03-01

## README

# Nano-Base32

A small, quick, self-contained implementation of the Base32 encoding/decoding scheme used by the cryptocurrency Nano.

## Installation

```sh
$ yarn add nano-base32
```

or

```sh
$ npm install --save nano-base32
```

## Usage

```js
const nanoBase32 = require('nano-base32')
const hexToArrayBuffer = require('hex-to-array-buffer')
const arrayBufferToHex = require('array-buffer-to-hex')
const blake = require('blakejs')

const pubKey = '0D7471E5D11FADDCE5315C97B23B464184AFA8C4C396DCF219696B2682D0ADF6'
const buffer = new Uint8Array(hexToArrayBuffer(pubKey))

const encoded = nanoBase32.encode(buffer)
// => 15dng9kx49xfumkm4q6qpaxneie6oynebiwpums3ktdd6t3f3dhp

const checksum = blake.blake2b(buffer, null, 5).reverse()
// => Uint8Array [ 33, 233, 215, 36, 38 ]
const checksumEncoded = nanoBase32.encode(checksum)
// => 69nxgb38

const address = `xrb_${encoded}${checksumEncoded}`
// => xrb_15dng9kx49xfumkm4q6qpaxneie6oynebiwpums3ktdd6t3f3dhp69nxgb38

const decoded = nanoBase32.decode(encoded)
const decodedHex = arrayBufferToHex(decoded.buffer).toUpperCase()
// => 0D7471E5D11FADDCE5315C97B23B464184AFA8C4C396DCF219696B2682D0ADF6

const decodedChecksum = nanoBase32.decode(checksumEncoded)
// => Uint8Array [ 33, 233, 215, 36, 38 ]
```

## API

```javascript
/**
 * Decodes a Nano-implementation Base32 encoded string into a Uint8Array
 * @param {string} input A Nano-Base32 encoded string
 * @returns {Uint8Array}
 */
 function decode (input)

/**
 * Encode provided Uint8Array using the Nano-specific Base-32 implementeation.
 * @param {Uint8Array} view Input buffer formatted as a Uint8Array
 * @returns {string}
 */
function encode (view)
 ```

 ## Running Tests
 ```
 $ git clone https://github.com/termhn/node-base32
 $ cd node-base32
 $ yarn install
 $ yarn test
 ```

## Credit
Encoding and decoding algorithms based on:
- [base32-encode](https://github.com/LinusU/base32-encode) - Base32 encoder
- [base32-decode](https://github.com/LinusU/base32-decode) - Base32 decoder

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