# cwi-array-encoding

> Efficiently encode Uint8Arrays as base64 strings

Latest version **0.1.11** (published 2023-12-10) · Open BSV License license · 0 weekly downloads

## Install

```sh
npm install cwi-array-encoding
pnpm add cwi-array-encoding
yarn add cwi-array-encoding
bun add cwi-array-encoding
```

## 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.1.11 |
| Published | 2023-12-10 |
| First published | 2022-09-06 |
| Weekly downloads | 0 |
| License | Open BSV License |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 90.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Peer-to-Peer Privacy Systems Research LLC |
| Maintainers | tonesnotes, braydude, tyeverett |

## Links

- npm: https://www.npmjs.com/package/cwi-array-encoding
- Repository: https://github.com/p2ppsr/array-encoding
- Homepage: https://github.com/p2ppsr/array-encoding#readme
- Issues: https://github.com/p2ppsr/array-encoding/issues
- npm.io page: https://npm.io/package/cwi-array-encoding

## Recent versions

- 0.1.11 (latest) — 2023-12-10
- 0.1.10 — 2023-12-09
- 0.1.8 — 2022-12-27
- 0.1.7 — 2022-12-27
- 0.1.5 — 2022-09-06

## README

# cwi-array-encoding

Efficiently encode Uint8Arrays as base64 strings

## Usage

```js
import { encodeUint8AsString, decodeUint8FromString } from '@cwi/array-encoding'

// Start with a Uint8Array of any length
const originalArray = new Uint8Array([1, 2, 3, 4])

// encodeUint8ArrayAsString produces an efficiently-encoded base64 string
const encodedString = encodeUint8AsString(originalArray)

// To get your original array back, just pass the base64 string to decodeUint8FromString
const decodedArray = decodeUint8FromString(encodedString)

// You can also encode and decode hex strings by specifiying the format (defaults to base64)
const encodedStringAsHex = encodeUint8AsString(originalArray, 'hex')
const decodedArrayFromHex = decodeUint8FromString(encodedStringAsHex, 'hex')
```

## API

### `encodeUint8AsString(Uint8Array, outputFormat) => string`

This function takes an arbitrary Uint8Array of any length and returns an efficiently-encoded base64 or hex string that can be easily stored in a database or sent over the network.

### `decodeUint8FromString(string, format) => Uint8Array`

This function takes a base64 or hex encoded string that was produced by the `encodeUint8AsString` function and returns the original Uint8Array.

## Testing

If any changes are required to this library, please maintain an adequate level of test coverage for critical production environments.

## License

The license for the code in this repository is the Open BSV License.

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