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

secure-json-encryptor

v1.0.4

Published

A zero-dependency library for secure JSON encryption/decryption using Web Crypto API

Readme

Secure JSON Encryptor 🔐

npm version License: MIT Zero Dependencies

A lightweight, zero-dependency library for secure JSON encryption and decryption using the native Web Crypto API. Works seamlessly across React Native, Node.js, and modern browsers.

✨ Features

  • 🔒 Zero Dependencies — Built entirely on the native Web Crypto API (no third-party libraries required)
  • 🔐 AES-GCM Encryption - Authenticated encryption with 256-bit keys
  • 📱 Cross-Platform - React Native, Node.js, and browser compatible
  • 🚀 Simple API - Easy-to-use encrypt/decrypt functions
  • 📦 Ultra Lightweight - Less than 2KB minified
  • 🛡️ TypeScript Ready - Includes full TypeScript definitions
  • 🧪 Well Tested - Comprehensive test coverage

🌐 Platform Compatibility

Supports all environments with Web Crypto API:

  • Android (React Native 0.71+)
  • iOS (React Native 0.71+)
  • Chrome 37+
  • Firefox 34+
  • Safari 14+
  • Edge 79+
  • Node.js 15+

📦 Installation

npm install secure-json-encryptor
# or
yarn add secure-json-encryptor
# or
pnpm add secure-json-encryptor

📦 Usaging

import { encrypt, decrypt } from 'secure-json-encryptor';

const secretKey = 'your-secret-password-here';
const sensitiveData = {
  username: 'john_doe',
  token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
  preferences: { theme: 'dark', notifications: true }
};

// Encrypt data
const encrypted = await encrypt(sensitiveData, secretKey);
console.log('Encrypted:', encrypted); // Base64 string

// Decrypt data
const decrypted = await decrypt(encrypted, secretKey);
console.log('Decrypted:', decrypted); // Original object

📱 React Native Example

import React, { useState } from 'react';
import { encrypt, decrypt } from 'secure-json-encryptor';
import AsyncStorage from '@react-native-async-storage/async-storage';

const App = () => {
  const [data, setData] = useState(null);
  
  const saveSecureData = async (userData) => {
    const SECRET_KEY = 'your-app-secret-key';
    
    // Encrypt before storing
    const encrypted = await encrypt(userData, SECRET_KEY);
    await AsyncStorage.setItem('user_data', encrypted);
  };
  
  const loadSecureData = async () => {
    const SECRET_KEY = 'your-app-secret-key';
    const encrypted = await AsyncStorage.getItem('user_data');
    
    if (encrypted) {
      try {
        const decrypted = await decrypt(encrypted, SECRET_KEY);
        setData(decrypted);
      } catch (error) {
        console.error('Failed to decrypt:', error);
      }
    }
  };
  
  // Component implementation...
};

🖥️ Node.js Example

const { encrypt, decrypt } = require('secure-json-encryptor');
const fs = require('fs').promises;

// Encrypt and save sensitive config
async function saveConfig(config) {
  const secretKey = process.env.APP_SECRET_KEY;
  const encrypted = await encrypt(config, secretKey);
  await fs.writeFile('config.encrypted', encrypted);
}

// Load and decrypt config
async function loadConfig() {
  const secretKey = process.env.APP_SECRET_KEY;
  const encrypted = await fs.readFile('config.encrypted', 'utf8');
  return await decrypt(encrypted, secretKey);
}

🔐 Security Best Practices

Key Management:

javascript
// Good: Use environment variables
const secretKey = process.env.ENCRYPTION_SECRET;

// Bad: Hardcoded keys
const secretKey = 'my-hardcoded-key';

📄 License

Copyright (c) 2024 Secure JSON Encryptor
Licensed under the MIT License (the "License");  
you may not use this file except in compliance with the License.  
You may obtain a copy of the License at:

[https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)

Unless required by applicable law or agreed to in writing, this software  
is provided on an "AS IS" basis, without any warranties or conditions of any kind,  
either express or implied, including but not limited to the warranties of  
merchantability, fitness for a particular purpose, and non-infringement.  
See the License for the specific language governing permissions and  
limitations under the License.