Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coboxcoop/crypto-encoder

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coboxcoop/crypto-encoder

A simple crypto encoder compatible with hypercore

  • 1.0.0-alpha.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

crypto-encoder

A simple hypercore-compatible crypto encoder.

Example

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

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

const feed = hypercore(storage, { valueEncoding })

API

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

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

const nonce = Encoder.generateNonce()

Generate a random nonce 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:
    • ops.nonce a buffer containing a 24 byte nonce
    • 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] }

Keywords

FAQs

Package last updated on 29 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc