README
tweetnacl-util-js-esm
tweetnacl-util-js-esm but with ESM support
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 packages:
@stablelib/utf8 for UTF-8 encoding/decoding (note that the names of operations are reversed compared to this package):
npm install @stablelib/utf8
@stablelib/base64 for constant-time Base64 encoding/decoding:
npm install @stablelib/base64
Documentation
util.decodeUTF8(string)
Decodes string and returns Uint8Array
of bytes.
util.encodeUTF8(array)
Encodes Uint8Array
or Array
of bytes into string.
util.decodeBase64(string)
Decodes Base-64 encoded string and returns Uint8Array
of bytes.
util.encodeBase64(array)
Encodes Uint8Array
or Array
of bytes into string using Base-64 encoding.