Socket
Book a DemoInstallSign in
Socket

ara-secret-storage

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ara-secret-storage

ARA RFC 0001 Secret Storage implementation

latest
npmnpm
Version
0.2.1
Version published
Weekly downloads
7
16.67%
Maintainers
1
Weekly downloads
 
Created
Source

ara-secret-storage

This module implements ARA RFC 0001.

Status

Stable

Installation

$ npm install arablocks/ara-secret-storage

From Source

Please make sure have the latest version of nodejs and make installed on your machine. This will only work for Linux and macOS users.

$ git clone git@github.com:AraBlocks/ara-secret-storage.git
$ cd ara-secret-storage
$ make
$ make install # you may need sudo

API

storage.encrypt(value, opts)

Encrypts value into a "crypto" object configured by an initialization vector (iv) and secret key (key) with optional cipher and digest algorithms.

const storage = require('ara-secret-storage')
const crypto = require('ara-crypto')

const message = Buffer.from('hello')
const key = Buffer.alloc(16).fill('key')
const iv = crypto.randomBytes(16)
const enc = storage.encrypt(message, { key, iv })
console.log(enc)

Should output:

{ id: 'a83f4ea0-f486-4d32-82ec-8a047bd085a7',
  version: 0,
  crypto:
    { cipherparams: { iv: 'a292924998b67cf8d1abcb5f1174e7de' },
      ciphertext: '5e46475c92',
      cipher: 'aes-128-ctr',
      digest: 'sha1',
      mac: '702deecad7b3bf12ae9bcff7cfd13ee24e43cd13' } }

storage.decrypt(value, opts)

Decrypt an encrypted "crypto" object into the originally encoded buffer.

Where

  • value - is a JSON object from the output of storage.encrypt()
  • opts - An object containing parameters used for decryption that can overload the cipher parameters found in the secret storage JSON object.
const storage = require('ara-secret-storage')
const crypto = require('ara-crypto')

const message = Buffer.from('hello')
const key = Buffer.alloc(16).fill('key')
const iv = crypto.randomBytes(16)
const enc = storage.encrypt(message, { key, iv })
const dec = storage.decrypt(enc, { key })
assert(0 == Buffer.compare(dec, message))

Contributing

Releases follow Semantic Versioning

See Also

License

LGPL-3.0

Keywords

ara

FAQs

Package last updated on 21 Apr 2021

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