# tweetnacl-util

> String encoding utilitlies extracted from TweetNaCl.js

Latest version **0.15.1** (published 2020-01-29) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install tweetnacl-util
pnpm add tweetnacl-util
yarn add tweetnacl-util
bun add tweetnacl-util
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.15.1 |
| Published | 2020-01-29 |
| First published | 2016-02-19 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | TweetNaCl-js contributors |
| Maintainers | dchest |
| Keywords | base64, utf8, string, encoding |

## Links

- npm: https://www.npmjs.com/package/tweetnacl-util
- Repository: https://github.com/dchest/tweetnacl-util-js
- Issues: https://github.com/dchest/tweetnacl-util-js/issues
- npm.io page: https://npm.io/package/tweetnacl-util

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

- 0.15.1 (latest) — 2020-01-29
- 0.15.0 — 2017-03-19
- 0.14.0 — 2017-02-22
- 0.13.5 — 2016-12-13
- 0.13.4 — 2016-12-08
- 0.13.3 — 2016-02-19

## README

tweetnacl-util-js
=================

String encoding utilities extracted from early versions of <https://github.com/dchest/tweetnacl-js>

Notice
------

Encoding/decoding functions in this package are correct,
however their performance and wide compatibility with uncommon runtimes is not
something that is considered important compared to the simplicity and size of
implementation. For example, they don't work under
React Native.

Instead of this package, I strongly recommend using my [StableLib](https://github.com/StableLib/stablelib) packages:

* [@stablelib/utf8](https://www.stablelib.com/modules/_utf8_utf8_.html) for UTF-8
  encoding/decoding (note that the names of operations are reversed compared to
  this package): `npm install @stablelib/utf8`

* [@stablelib/base64](https://www.stablelib.com/modules/_base64_base64_.html) for
  constant-time Base64 encoding/decoding: `npm install @stablelib/base64`


Installation
------------

Use a package manager:

[Bower](http://bower.io):

    $ bower install tweetnacl-util

[NPM](https://www.npmjs.org/):

    $ npm install tweetnacl-util

or [download source code](https://github.com/dchest/tweetnacl-util-js/releases).


Usage
------

To make keep backward compatibility with code that used `nacl.util` previously
included with TweetNaCl.js, just include it as usual:

```
<script src="nacl.min.js"></script>
<script src="nacl-util.min.js"></script>
<script>
  // nacl.util functions are now available, e.g.:
  // nacl.util.decodeUTF8
</script>
```

When using CommonJS:

```
var nacl = require('tweetnacl');
nacl.util = require('tweetnacl-util');
```


Documentation
-------------

#### nacl.util.decodeUTF8(string)

Decodes string and returns `Uint8Array` of bytes.

#### nacl.util.encodeUTF8(array)

Encodes `Uint8Array` or `Array` of bytes into string.

#### nacl.util.decodeBase64(string)

Decodes Base-64 encoded string and returns `Uint8Array` of bytes.

#### nacl.util.encodeBase64(array)

Encodes `Uint8Array` or `Array` of bytes into string using Base-64 encoding.

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