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 🙏

© 2026 – Pkg Stats / Ryan Hefner

encrypt-decrypt-js

v1.0.0

Published

EncryptDecryptJS is a lightweight **encryption and decryption library** for **React** and **Node.js**.

Readme

EncryptDecryptJS: Secure Encryption & Decryption for React & Node.js

🔐 Overview

EncryptDecryptJS is a lightweight encryption and decryption library for React and Node.js.

✨ Features

  • AES-GCM and RSA-OAEP encryption
  • HMAC (SHA-256) for integrity verification
  • Base64-encoded key support for easy key sharing
  • Secure key storage in IndexedDB
  • Asynchronous API with Promises
  • Fully compatible with React & Node.js

📦 Installation

npm i encrypt-decrypt-js

🔑 Generating & Using Keys

Generate an AES Key

import { generateAESKey, exportAESKeyToBase64 } from "encrypt-decrypt-js";

async function generateKey() {
  const key = await generateAESKey();
  const base64Key = await exportAESKeyToBase64(key);
  console.log("Generated AES Key (Base64):", base64Key);
}

generateKey();

Generate RSA Keys

import { generateRSAKey, exportRSAKeyToBase64 } from "encrypt-decrypt-js";

async function generateRSAKeys() {
  const { publicKey, privateKey } = await generateRSAKey();
  const publicKeyBase64 = await exportRSAKeyToBase64(publicKey, false);
  const privateKeyBase64 = await exportRSAKeyToBase64(privateKey, true);

  console.log("Public Key (Base64):", publicKeyBase64);
  console.log("Private Key (Base64):", privateKeyBase64);
}

generateRSAKeys();

🔒 Encryption & Decryption

AES-GCM Encryption & Decryption

import { encrypt, decrypt } from "encrypt-decrypt-js";

async function testAES() {
  const keyBase64 = "your-base64-encoded-key";
  const encryptedData = await encrypt("Hello, World!", { type: "AES-GCM" }, keyBase64);
  console.log("Encrypted:", encryptedData);
  
  const decryptedData = await decrypt(encryptedData, { type: "AES-GCM" }, keyBase64);
  console.log("Decrypted:", decryptedData);
}

testAES();

RSA-OAEP Encryption & Decryption

import { encrypt, decrypt } from "encrypt-decrypt-js";

async function testRSA() {
  const publicKeyBase64 = "your-public-key-in-base64";
  const privateKeyBase64 = "your-private-key-in-base64";

  const encryptedData = await encrypt("Hello, RSA!", { type: "RSA-OAEP" }, publicKeyBase64);
  console.log("Encrypted:", encryptedData);

  const decryptedData = await decrypt(encryptedData, { type: "RSA-OAEP" }, privateKeyBase64);
  console.log("Decrypted:", decryptedData);
}

testRSA();

🔏 HMAC: Message Integrity Verification

Generate & Verify HMAC Signature

import { generateHMACKey, generateHMAC, verifyHMAC, exportHMACKeyToBase64 } from "encrypt-decrypt-js";

async function testHMAC() {
  const hmacKey = await generateHMACKey();
  const hmacKeyBase64 = await exportHMACKeyToBase64(hmacKey);
  
  const message = "Hello, Secure World!";
  const signature = await generateHMAC(message, hmacKey);
  console.log("HMAC Signature:", signature);
  
  const isValid = await verifyHMAC(message, signature, hmacKey);
  console.log("Signature Valid:", isValid);
}

testHMAC();

💾 Secure Key Storage (IndexedDB)

Store & Retrieve Keys

import { storeKey, getKey, deleteKey } from "encrypt-decrypt-js";

async function manageKeys() {
  const key = await generateAESKey();
  await storeKey("my-encryption-key", key);
  
  const retrievedKey = await getKey("my-encryption-key");
  console.log("Retrieved Key:", retrievedKey);

  await deleteKey("my-encryption-key");
  console.log("Key deleted");
}

manageKeys();

🛠️ API Reference

🔑 Key Management

| Function | Description | |----------|-------------| | generateAESKey() | Generate a new AES-GCM key | | generateRSAKey() | Generate a new RSA-OAEP key pair | | exportAESKeyToBase64(key) | Export AES key as Base64 | | exportRSAKeyToBase64(key, isPrivate) | Export RSA key as Base64 | | importAESKeyFromBase64(base64Key) | Import AES key from Base64 | | importRSAKeyFromBase64(base64Key, isPrivate) | Import RSA key from Base64 |

🔒 Encryption & Decryption

| Function | Description | |----------|-------------| | encrypt(data, options, keyBase64, hmacKeyBase64?) | Encrypt data (AES or RSA) | | decrypt(encryptedData, options, keyBase64, hmacKeyBase64?) | Decrypt data (AES or RSA) |

🖋️ HMAC (Integrity Verification)

| Function | Description | |----------|-------------| | generateHMACKey() | Generate a new HMAC key | | generateHMAC(message, key) | Create an HMAC signature for a message | | verifyHMAC(message, hmac, key) | Verify an HMAC signature |

💾 Secure Key Storage

| Function | Description | |----------|-------------| | storeKey(name, key) | Store a key securely in IndexedDB | | getKey(name) | Retrieve a stored key from IndexedDB | | deleteKey(name) | Delete a stored key from IndexedDB |

📧 Contact

For questions or support, feel free to reach out.


🚀 CryptoLib: Secure your React & Node.js applications today!