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

encryption-for-node

v1.1.7

Published

Portable Crypto libraries for Node and Browsers

Downloads

53

Readme

encryption-for-node

14 vanilla TypeScript, 0 dependencies portable encryption libraries. Great for Node servers or Browsers.

Encryptions

  • AES
  • Aria
  • Blowfish
  • Camellia
  • Cast128
  • ChaCha20
  • Triple DES
  • IDEA
  • MARS
  • MISTY1
  • SEED
  • Serpent
  • SM4
  • Twofish

Installation

npm install encryption-for-node

Features

  • Barebones, small size, no bulk encryption methods.
  • Runs ECB or CBC modes.
  • Static or PKCS padding.
  • Accepts Buffer or Uint8Array. Returns the same type.
  • Easily modifiable to fit any needs.

Require or Import

//For Node:
const {CAST128} = require('encryption-for-node');
//For Browser:
import {CAST128} from 'encryption-for-node';

Use

All encryptions classes follow the same format. Use cipher.set_key then cipher.set_iv for CBC mode. If cipher.set_iv is not set, runs in ECB mode. If static padding number is not set, uses PKCS padding on last block if needed.

//encrypt:
const cipher = new Blowfish();
cipher.set_key(Uint8ArrayOrBufferKey);
cipher.set_iv(Uint8ArrayOrBufferIV);
var paddingNumber = 0xFF; //If padding number is not set, uses PKCS padding.
const CipherText = cipher.encrypt(Uint8ArrayOrBufferText, paddingNumber);
//decrypt
const cipher = new Blowfish();
cipher.set_key(Uint8ArrayOrBufferKey);
cipher.set_iv(Uint8ArrayOrBufferIV);
var paddingNumberOrTrue = 0xFF; //Will check the last block and remove if padded is ``number``. Will remove PKCS if ``true``.
const DecryptedUInt8ArrayOrBuffer = cipher.decrypt(ciphertext, paddingNumberOrTrue);

Note: Most encryptions can be run multiple times once setup with a key. IV will need to be reset for CBC mode before each use.

Tech

|Encryption |Key Length |IV Length | | :--- | :----: | :--- | |AES |16, 24 or 32 byte key |16 byte IV | |ARIA |16, 24 or 32 byte key |same as key| |BLOWFISH |Up to 56 byte key |8 byte IV | |CAMELLIA |16, 24 or 32 byte key |16 byte IV | |CAST128 |16 byte key |8 byte IV | |*CHACHA20 |32 byte key, 12 byte nonce|16 byte IV | |DES3 |8 byte key |8 byte IV | |IDEA |16 byte key |8 byte IV | |MARS |16, 24 or 32 byte key |16 byte IV | |MISTY1 |16 byte key |8 byte IV | |SEED |16 byte key |16 byte IV | |SERPENT |16, 24 or 32 byte key |16 byte IV | |SM4 |16 byte key |16 byte IV | |TWOFISH |16 byte key |16 byte IV |

*key must be reset after each use

License

MIT

Disclaimer

This library spawned from a project where issues with different Node versions meant not having the same access to some of these encryptions. I created these vanilla JavaScript versions of these encryptions so we could implement them in different environments and have them all match. I do not know how they hold up speed or performance wise against something more direct like a C++ source code, as the goal here was flexible. Some encryptions were limited in key length as it would have required extra coding outside of the function of the project. All libraries are presented as is, I take no responsibility for outside use.

If you plan to implement these encryption libraries for anything other than personal or educational use, please be sure you have the appropriate permissions from the original owner of the cipher.