1.0.6 • Published 3 years ago

hypercore-encrypt v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

hypercore-encrypt

Hypercore encrypt enables block encryption for Hypercore v10 with authenticated encryption keys.

npm i hypercore-encrypt

Build Status

Usage

const Hypercore = require('hypercore-encrypt')

const feed = new Hypercore('./my-encrypted-dataset', null, { 
  encryptionKey: key, 
  valueEncoding: 'json',
  skipFirstBlock: false // remove this option if the feed is being used in something like Hyperbee
})

await feed.ready()

feed.append('hello world')
feed.get(0, console.log) // decrypts block 0 and prints hello world

API

const feed = new Hypercore(storage, [key], [options])

Hypercore-encrypt mimics Hypercore v10's API except an encryption key can be passed into the options to encrypt and decipher blocks.

{
  encryptionKey: key, // All blocks will be encrypted and deciphered with this AEAD key
  skipFirstBlock: true // Skip encrypting the header block when using this in conjunction with something like Hyperbee
}
// Initializing a new feed without an encryption key will automatically generate a new one
const feed = new Hypercore('./my-encrypted-dataset', null, { valueEncoding: 'json' })

const key = feed.encryptionKey.tostring('hex')

// Initialize a new feed with an existing key
const feed = new Hypercore('./cloned-encrypted-dataset', feed.key, { encryptionKey: key, valueEncoding: 'json' })

License

MIT

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago