npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

soya-sauce

v0.2.1

Published

An easy-to-use, and convenient libsodium wrapper.

Downloads

11

Readme

Installation

npm install soya-sauce

Usage

Let's say Badri 💁‍♂️ and Akinyi 💁‍♀️ want to be able to communicate under the following conditions...

  • The message cannot be read while stored.
  • The message cannot be intercepted and read in transit.

In order to do this, we can generate a private-public key-pair for both Badri and Akinyi, in which the public key can be freely shared amongst themselves and publicly, and in which the private key will be securely held.

While the public key allows you to encrypt a message intended for a recipient, the private key is the only key which allows you to decrypt the message. Granted the private key does not get into the hands of others, messages intended for a recipient cannot be read.

import { SecretBox, generateKeyPair } from "soya-sauce";

const box = new SecretBox().withoutMasterKey();

const badri = generateKeyPair();
const akinyi = generateKeyPair();

(async function encryptThenDecrypt() {
  const messageForBadriFromAkinyi = await box.encrypt("Hey, how are you? 🙃", {
    public: badri.public,
    private: akinyi.private,
  });

  console.log(messageForBadriFromAkinyi); // <Buffer 95 ce 66 87 d6 d5 31 ...

  const decryptedMessageFromAkinyi = await box.decrypt(
    messageForBadriFromAkinyi,
    {
      public: akinyi.public,
      private: badri.private,
    }
  );

  console.log(decryptedMessageFromAkinyi.toString()); // Hey, how are you? 🙃
})();

If you want to add a master key to this flow, simply initialize the SecretBox class using the withMasterKey method. This will encrypt each message using a hash generated from the provided text, increasing the resulting time complexity.

import { SecretBox, generateKeyPair } from "soya-sauce";

const box = new SecretBox().withMasterKey("<MASTER_KEY>");

const badri = generateKeyPair();
const akinyi = generateKeyPair();

(async function encryptThenDecrypt() {
  const messageForBadriFromAkinyi = await box.encrypt("Hey, how are you? 🙃", {
    public: badri.public,
    private: akinyi.private,
  });

  console.log(messageForBadriFromAkinyi); // <Buffer f5 cc ad 67 7f 10 d1 ...

  const decryptedMessageFromAkinyi = await box.decrypt(
    messageForBadriFromAkinyi,
    {
      public: akinyi.public,
      private: badri.private,
    }
  );

  console.log(decryptedMessageFromAkinyi.toString()); // Hey, how are you? 🙃
})();

Disclaimer

You should know how to properly store, share, transmit, generate, and use secrets before using this library. Usage of this library will not actually automagically make you not !@#% something up. Proceed with caution, and store user data safely.