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

slow-cipher

v0.1.1

Published

Intentionally slow cipher

Downloads

2

Readme

Slow Cipher

A combination of AES and PBKDF2 (Password-Based Key Derivation Function 2) methods that is designed to take some time before it is possible to decrypt a secret message.

One particular use case could be anonymous delayed secret message store, that is revealed after some time of doing calculations.

Since it takes long time to encode the key, it is safe to keep initial keys within container, an example can be generated

Check out demo

Install

yarn add slow-cipher

Encrypt/Decrypt Example

Run using command: node --es-module-specifier-resolution=node examples/encrypt.js

import slowCipher from 'slow-cipher';

const message = 'some secret message';
const key = slowCipher.randomHex();
const iv = slowCipher.randomHex();
const salt = slowCipher.randomHex();
const stepCount = 500; // about 30s

// compute key and encrypt will take about 30s based on stepCount
const result = await slowCipher.encrypt(message, key, iv, salt, stepCount, 0);

console.log('cipherText', result.cipherText);

// compute key from the start and decrypt, will take same amount of time as encrypt method
const originalMessage = await slowCipher.decrypt(result.cipherText, key, iv, salt, stepCount, 0);
console.log('originalMessage', originalMessage);

// if you have saved computedKeyHex, then it will be very fast to encrypt/decrypt
const resultFast = await slowCipher.encrypt(message, result.computedKeyHex, iv, salt, stepCount, stepCount - 1);

const fastOriginalMessage = await slowCipher.decrypt(resultFast.cipherText, result.computedKeyHex, iv, salt, stepCount, stepCount - 1);
console.log('fastOriginalMessage', fastOriginalMessage);

View Example

First run yarn build.

Run using command: node --es-module-specifier-resolution=node examples/view.js.

import slowCipher from 'slow-cipher';

slowCipher.slowCipherView('#root', uuid, cipherText, keyHex, saltHex, ivHex, stepCount);

Make self executable and save to file:

import fs from 'fs';

const cipherText = '<cipherText>';
const key = '<key>';
const iv = '<iv>';
const salt = '<salt>';
const stepCount = 500; 

let script = fs.readFileSync('./dist/view.js').toString();;
const exportIndex = script.lastIndexOf('export');
script = script.substring(0, exportIndex);
script = `
(() => {
  ${script}
  ;
  const rootEl = document.createElement('div');
  rootEl.id = 'view_someUUID';
  rootEl.style.cssText = 'position: fixed; top: 50px;';

  document.body.append(rootEl);
  window.slowCipherView('view_someUUID', 'someUUID', '${cipherText}', '${key}', '${salt}', '${iv}', ${stepCount});
})()
`

fs.writeFileSync('view_browser.js', script);