A simple crypto encoder compatible with hypercore
ameba23 b8889d4767 1.0.2 7 months ago
test util for test 1 year ago
LICENSE readme 1 year ago
README.md readme 1 year ago
index.js default to encoder 7 months ago
package.json 1.0.2 7 months ago
yarn.lock yarn lock 1 year ago



A simple hypercore-compatible crypto encoder.


const hypercore = require('hypercore')
const Encoder = require('.')

const encryptionKey = Encoder.encryptionKey()
const valueEncoding = Encoder(encrytionKey, { valueEncoding: 'utf-8' })

const feed = hypercore(storage, { valueEncoding })


const Encoder = require('.')
const encryptionKey = Encoder.encryptionKey()

Generate a random 32 byte key to be used to encrypt.

const valueEncoding = Encoder(encryptionKey, opts)

Returns a message encoder used for encrypting messages in hypercore.

  • encryptionKey must be a buffer of length Encoder.KEYBYTES.
  • opts is an optional object which may contain:
    • opts.valueEncoder, an additional encoder to be used before encryption. May be one of:
    • The string ‘utf-8’ - utf-8 encoded strings will be assumed.
    • The string ‘JSON’ - JSON encoding will be assumed.
    • A custom encoder of the form { encode: [function] decode: [function] }