String encoding utilities extracted from https://github.com/dchest/tweetnacl-js
Encoding/decoding functions are provided for convenience. They 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. Please use better third-party libraries if you need to.
Use a package manager:
$ bower install tweetnacl-util
NPM:
$ npm install tweetnacl-util
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');
Decodes string and returns Uint8Array
of bytes.
Encodes Uint8Array
or Array
of bytes into string.
Decodes Base-64 encoded string and returns Uint8Array
of bytes.
Encodes Uint8Array
or Array
of bytes into string using Base-64 encoding.