npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

encrypt-stack

v1.0.2

Published

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

Downloads

11

Readme

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