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

@deadmansswitch/encryption

v1.0.0

Published

Cross-platform encryption library for React Native and React web applications with password-based encryption

Readme

@deadmansswitch/encryption

Cross-Platform Encryption Library

A lightweight, cross-platform encryption library that works seamlessly with both React Native and React web applications. Uses password-based encryption with PBKDF2 key derivation and AES-GCM encryption.

Features

  • Cross-platform: Works in React Native and React web/Next.js
  • Password-based encryption: Secure PBKDF2 key derivation
  • AES-GCM encryption: Strong encryption with built-in authentication
  • TypeScript support: Full type definitions included
  • React Native: Encryption and decryption
  • React Web: Decryption only (as requested)

Installation

npm install @deadmansswitch/encryption

For React Native, you'll also need to install the crypto dependency:

npm install react-native-quick-crypto

After installation, you'll need to complete the platform setup. For React Native 0.60+, run:

cd ios && pod install

Usage

React Native (Encryption + Decryption)

import { encrypt, decrypt } from '@deadmansswitch/encryption';

// Encrypt data
const encryptData = async () => {
  const result = await encrypt('Hello, World!', {
    password: 'your-secure-password'
  });
  
  console.log('Encrypted:', result.encryptedData);
  console.log('Salt:', result.salt);
  console.log('IV:', result.iv);
  
  return result;
};

// Decrypt data
const decryptData = async (encryptionResult) => {
  const decrypted = await decrypt({
    password: 'your-secure-password',
    encryptedData: encryptionResult.encryptedData,
    salt: encryptionResult.salt,
    iv: encryptionResult.iv
  });
  
  console.log('Decrypted:', decrypted); // "Hello, World!"
  return decrypted;
};

React Web/Next.js (Decryption Only)

import { decrypt } from '@deadmansswitch/encryption';

// Decrypt data received from React Native
const decryptData = async () => {
  const decrypted = await decrypt({
    password: 'your-secure-password',
    encryptedData: 'encrypted-data-from-rn',
    salt: 'salt-from-rn',
    iv: 'iv-from-rn'
  });
  
  console.log('Decrypted:', decrypted);
  return decrypted;
};

API Reference

encrypt(data: string, options: EncryptionOptions): Promise<EncryptionResult>

Encrypts a string using password-based encryption.

Parameters:

  • data - The string to encrypt
  • options - Encryption options
    • password - The password to use for encryption
    • iterations? - Number of PBKDF2 iterations (default: 100000)
    • keyLength? - Key length in bits (default: 256)

Returns: Promise resolving to an EncryptionResult containing:

  • encryptedData - Base64 encoded encrypted data
  • salt - Base64 encoded salt
  • iv - Base64 encoded initialization vector

decrypt(options: DecryptionOptions): Promise<string>

Decrypts data using password-based decryption.

Parameters:

  • options - Decryption options
    • password - The password used for encryption
    • encryptedData - Base64 encoded encrypted data
    • salt - Base64 encoded salt
    • iv - Base64 encoded initialization vector
    • iterations? - Number of PBKDF2 iterations (default: 100000)
    • keyLength? - Key length in bits (default: 256)

Returns: Promise resolving to the decrypted string

Security Notes

  • Uses PBKDF2 with 100,000 iterations by default
  • Uses AES-GCM for authenticated encryption
  • Generates random salt and IV for each encryption
  • Password should be strong and stored securely
  • Never hardcode passwords in your application

Platform Detection

The library automatically detects the platform and uses the appropriate implementation:

  • React Native: Uses react-native-quick-crypto for native performance
  • Web/Next.js: Uses Web Crypto API

TypeScript

Full TypeScript support is included with exported interfaces:

import type { 
  EncryptionOptions, 
  EncryptionResult, 
  DecryptionOptions 
} from '@deadmansswitch/encryption';

License

MIT