Skip to content
libsodium sealed cryptobox using tweetnacl
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Add build toolchain Sep 18, 2018
.travis.yml
LICENSE
README.md
index.js
package-lock.json bump a bunch of deps to update lodash for vuln Jul 30, 2019
package.json
test.js

README.md

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)
}
You can’t perform that action at this time.