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

crypto-utils-react

v1.2.2

Published

A simple AES-GCM encryption and decryption utility using Web Crypto API

Readme

📦 crypto-utils-react

A lightweight AES-GCM encryption and decryption utility for React and modern JavaScript applications. Built using the Web Crypto API, it provides secure and efficient methods to encrypt and decrypt sensitive frontend data such as login credentials, tokens, or form payloads before sending them to your backend.


🔐 Algorithm Used — AES-GCM

This library uses the AES-GCM (Advanced Encryption Standard - Galois/Counter Mode) algorithm, which offers:

  • ✅ Strong 256-bit symmetric encryption
  • ✅ Built-in data integrity check (authentication tag)
  • ✅ Support for modern browsers and secure contexts (HTTPS)

AES-GCM is a recommended algorithm by major security standards (NIST, OWASP) for frontend data encryption.


🚀 Installation

Install via npm:

npm install crypto-utils-react

Or with yarn:

yarn add crypto-utils-react

⚙️ Usage

1️⃣ Import functions

import { encrypt, decrypt } from "crypto-utils-react";

2️⃣ Encrypt & Decrypt Data (Frontend)

Example: Encrypting login credentials before sending to backend

import { encrypt, decrypt } from "crypto-utils-react";

const formData = {
  username: "test123",
  password: "Test@123",
  captcha: "ABT7Z",
};

const secretKey = "48jk3jh34093483784634908";

async function handleLogin() {
  const encryptedData = await encrypt((formData), secretKey);
  console.log("🔒 Encrypted Payload:", encryptedData);
  const decrypted = await decrypt(encryptedData, secretKey);
  console.log("🔒 decrypted Data:", encrypted);
}

🧠 Example Algorithm Flow

| Step | Process | Description | | ---- | ------------------------- | --------------------------------------------------------------------------------- | | 1 | PBKDF2 Key Derivation | Secret key is combined with a random salt to generate a strong derived key. | | 2 | AES-GCM Encryption | JSON payload is encrypted using AES-GCM with a random IV (initialization vector). | | 3 | Concatenation | Salt + IV + CipherText + AuthTag are merged into one byte array. | | 4 | Base64 Encoding | Final output is converted to Base64 string for easy transport over HTTP. |


🧩 Example Output

{
  "username": "test123",
  "password": "Test@123",
  "captcha": "ABT7Z"
}

After encryption →

AQIDCQsGHE8bUzZbSwYpBQIC... (Base64 string)

🧾 Notes

  • Works in modern browsers supporting window.crypto.subtle
  • Secure contexts required (https:// or localhost)
  • Not designed for Node.js environments without Web Crypto polyfill
  • Keep your secretKey safe and private — do not hardcode it

🛡️ License

MIT License © 2025 — Open-source & free to use in any React or JavaScript project.