Giter Site home page Giter Site logo

tweetnacl-util-js's Introduction

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

Installation

Use a package manager:

Bower:

$ bower install tweetnacl-util

NPM:

$ npm install tweetnacl-util

or download source code.

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.

tweetnacl-util-js's People

Contributors

dchest avatar andsdev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.