New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tweetsodium

Package Overview
Dependencies
Maintainers
14
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tweetsodium

libsodium sealed cryptobox using tweetnacl

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67K
increased by0.55%
Maintainers
14
Weekly downloads
 
Created
Source

⚠️ tweetsodium is unmaintained ⚠️

Consider using libsodium.js, maintained by the same author as libsodium. For example:

import libsodium from "libsodium-wrappers";

// Compatible with the same `Uint8Array` arguments as `tweetsodium.seal()`
async function async_encrypt(messageBytes, publicKey) {
  await libsodium.ready;
  return libsodium.crypto_box_seal(messageBytes, publicKey);
}

// Compatible with the same `Uint8Array` arguments as `tweetsodium.sealOpen()`
async function async_decrypt(messageBytes, publicKey, privateKey) {
  await libsodium.ready;
  return libsodium.crypto_box_seal_open(messageBytes, publicKey, privateKey);
}

Or if you are able to use top-level await:

import libsodium from "libsodium-wrappers";
await libsodium.ready;

// Use:
// - `libsodium.crypto_box_seal` instead of `tweetsodium.seal`
// - `libsodium.crypto_box_seal_open` instead of `tweetsodium.sealOpen`







tweetsodium Build Status

This library implements libsodium's sealed boxes using the tweetnacl-js and blakejs libraries.

Usage

const nacl = require("tweetnacl");
const sodium = require("tweetsodium");

// generate public key to use for encryption and coresponding secret key to use
// for decryption
const keyPair = nacl.box.keyPair();

// encrypts message string using public key
function encrypt(message) {
  const encoder = new TextEncoder();
  const messageBytes = encoder.encode(message);

  return sodium.seal(messageBytes, keyPair.publicKey);
}

// decrypts message using secret key
function decrypt(ciphertext) {
  const encoder = new TextEncoder();
  const ciphertextBytes = encoder.encode(ciphertext);

  return sodium.sealOpen(ciphertextBytes, keyPair.publicKey, keyPair.secretKey);
}

FAQs

Package last updated on 05 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc