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

encrypt-stack

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encrypt-stack

An encryption driver/stack to create a multi-layer encrypted workflow in Node.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Version License Author

Description

A nice multi-stack encryption module. Supports several levels of encryption, not that it's really neccessary. By default, the stack size is 3, utilising Blowfish with a 442-bit IV for each layer.

Installation

It's simple, just install it from npm. No external dependencies, should automatically install any additional npm packages.

npm i encrypt-stack

How to use

The module exports a class you can use for you key exchange, encryption and decryption. You can also specify your own encryption method to use, or a different key exchange protocol. By default, it's set to 'bf-cbc' and 'secp521r1'. Preferably, the key exchange would be Curve25519 (X25519), however 'secp521r1' is still not bad by any means. The encryption and key exchange method must be a string, referring to any supported NodeJS Crypto method respectively.

new EncryptionStack([stack size], [encryption method], [key exchange method])

Below is a simple alice and bob example of how the stack is used. Stack can be set to 1 to use just a single, simple encryption driver. However, it could also be set as high as 100 for some insane reason if you think that's a good idea.

const EncryptionStack = require("encrypt-stack");

const alice = new EncryptionStack();
const bob = new EncryptionStack();

alice.computeSecret(bob.keys());
bob.computeSecret(alice.keys());

const e = alice.encrypt("hello world"); // hex encrypted data of "hello world"
const d = bob.decrypt(e); // returns the original "hello world" string, if everything went well

const h = alice.hash("some data"); // returns a sha512 hash of "some data"

Benchmarks

I ran some super simple benchmarks, there's probably a better way of doing it, but it still produced some reasonable results. The number inside the brackets is the stack size, the first timing is the total stack time (for both clients), the second is the estimated time experienced by a single client (on key generation and single element encryption).

[1] 30ms : 15ms
[2] 50ms : 25ms
[3] 79ms : 39.5ms
[4] 106ms : 53ms
[5] 126ms : 63ms
[6] 154ms : 77ms
[7] 179ms : 89.5ms
[8] 202ms : 101ms
[9] 226ms : 113ms
[10] 254ms : 127ms
[11] 276ms : 138ms
[12] 316ms : 158ms
[13] 345ms : 172.5ms
[14] 410ms : 205ms
[15] 487ms : 243.5ms
[16] 627ms : 313.5ms
[17] 875ms : 437.5ms
[18] 1391ms : 695.5ms
[19] 2342ms : 1171ms
[20] 4236ms : 2118ms

Keywords

FAQs

Package last updated on 09 Oct 2019

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