JSPM

pull-secretstream

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q21109F
  • License MIT

libsodium secretstream as a pull stream

Package Exports

  • pull-secretstream
  • pull-secretstream/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-secretstream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull-secretstream

replacement for pull-box-stream using libsodium's secretstream

example

const { randomBytes } = require('crypto')
const pull = require('pull-stream')
const { KEYBYTES, createEncryptStream, createDecryptStream } = require('pull-secretstream')

// generate a random secret, `KEYBYTES` bytes long.
const key = randomBytes(KEYBYTES)

const plaintext1 = Buffer.from('hello world')

pull(
  pull.values([plaintext1]),

  // encrypt every byte
  createEncryptStream(key),

  // the encrypted stream
  pull.through((ciphertext) => {
    console.log('Encrypted: ', ciphertext)
  }),

  //decrypt every byte
  createDecryptStream(key),

  pull.concat((err, plaintext2) => {
    if (err) throw err
    console.log('Decrypted: ', plaintext2)
  }),
)