Need help with sodium-plus?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

paragonie
131 Stars 14 Forks Other 185 Commits 5 Opened issues

Description

Developer-friendly libsodium interface

Services available

!
?

Need anything else?

Contributors list

Sodium-Plus (Na+)

Build Status npm version

Sodium-Plus delivers a positive cryptography experience for JavaScript developers.

Sodium-Plus brings you all the benefits of using libsodium in your application without any of the headaches introduced by the incumbent APIs.

Sodium-Plus is permissively licensed (ISC) and free to use.

Features

  • Cross-platform.
  • Pluggable backend with an auto-loader:
  • Fully
    async
    /
    await
    ready (aside from object constructors).
  • Type-safe API:
    • Instead of just passing around
      Buffer
      objects and hoping you got your argument order correct,
      sodium-plus
      will throw an Error if you provide the wrong key type. This prevents you from accidentally introducing a severe security risk into your application.

Installing

Installing as a Node.js Module

With NPM:

npm install sodium-plus

You can optionally install

sodium-native
alongside
sodium-plus
if you want better performance.

The default configuration is a bit slower, but has a wider reach (e.g. web browsers).

Installing in a Web Page

See this section of the documentation for getting started with Sodium-Plus in a web browser.

Using Sodium-Plus in Your Projects

SodiumPlus is meant to be used asynchronously, like so:

const { SodiumPlus } = require('sodium-plus');

(async function() { // Select a backend automatically let sodium = await SodiumPlus.auto();

let key = await sodium.crypto_secretbox_keygen();
let nonce = await sodium.randombytes_buf(24);
let message = 'This is just a test message';
// Message can be a string, buffer, array, etc.

let ciphertext = await sodium.crypto_secretbox(message, nonce, key);
console.log(ciphertext);
let decrypted = await sodium.crypto_secretbox_open(ciphertext, nonce, key);
console.log(decrypted.toString('utf-8'));

})();

This should produce output similar to below (but with different random-looking bytes):

This is just a test message

Documentation

The documentation is available online on Github!

Support Contracts

If your company uses this library in their products or services, you may be interested in purchasing a support contract from Paragon Initiative Enterprises.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.