tweetsodium
libsodium sealed cryptobox using tweetnacl
Last updated 6 years ago by lgarron .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tweetsodium 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.5                                ...           latest (6 years ago)

5 Versions

  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |