Encrypt messages that only members from a set of hypercores can decrypt.
Encrypt messages that only members of a set of hypercores can decrypt.
Wraps private-box to support hypercore (ed25519) keys.
var hbox = require('hypercore-private-box')
var hypercore = require('hypercore')
var ram = require('random-access-memory')
var core = hypercore(ram, { valueEncoding: 'json' })
var text = Buffer.from('hello secure world!')
core.ready(function () {
var ctext = hbox.box(text, core)
console.log(ctext)
var result = hbox.unbox(ctext, core)
console.log(result)
})
outputs
<Buffer e6 48 ed 48 2a bc 81 3b ae 32 80 ... >
hello secure world!
var hbox = require('hypercore-private-box')
Encrypts the buffer buf
such that only the recipients
(array of 1-7 hypercores) can decrypt.
Decrypts the ciphertext buffer buf
using the hypercore core
. Returns undefined
if the buffer could not be decrypted.
With npm installed, run
$ npm install hypercore-private-box
Appreciation goes out to punkmonk (@EaYYQo5nAQRabB9nxAn5i2uiIZ665b90Qk2U/WHNVE8=.ed25519
) for helping me figure out how sodium works!
ISC