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

react-native-simple-crypto

v0.3.0

Published

A simpler React-Native crypto library

Readme

React Native Simple Crypto npm version

A simpler React-Native crypto library

Features

  • AES-128-CBC
  • HMAC-SHA256
  • SHA1
  • SHA256
  • SHA512
  • PBKDF2
  • RSA

Installation

npm install react-native-simple-crypto

For React Native 0.60+, autolinking handles native setup automatically. For iOS, run cd ios && pod install.

API

All methods are asynchronous and return promises (except for convert utils)

- AES
  - encrypt(text: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer)
  - decrypt(cipherText: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer)
- SHA
  - sha1(text: string)
  - sha1(text: ArrayBuffer)
  - sha256(text: string)
  - sha256(text: ArrayBuffer)
  - sha512(text: string)
  - sha512(text: ArrayBuffer)
- HMAC
  - hmac256(text: ArrayBuffer, key: ArrayBuffer)
- PBKDF2
  - hash(password: string, salt: ArrayBuffer, iterations: number, keyLength: number, hash: string)
- RSA
  - generateKeys(keySize: number)
  - sign(data: string, key: string, hash: string)
  - verify(data: string, secretToVerify: string, hash: string)
  - encrypt(data: string, key: string) (Expects UTF8 string data inputs)
  - decrypt(data: string, key: string) (Returns UTF8 string)
  - encrypt64(data: string, key: string) (Expects Base64 string data inputs)
  - decrypt64(data: string, key: string) (Returns Base64 string)
- utils
  - randomBytes(bytes: number)
  - convertArrayBufferToUtf8(input: ArrayBuffer)
  - convertUtf8ToArrayBuffer(input: string)
  - convertArrayBufferToBase64(input: ArrayBuffer)
  - convertBase64ToArrayBuffer(input: string)
  - convertArrayBufferToHex(input: ArrayBuffer)
  - convertHexToArrayBuffer(input: string)

NOTE: Supported hashing algorithms for RSA and PBKDF2 are:

"Raw" (RSA-only) | "SHA1" | "SHA224" | "SHA256" | "SHA384" | "SHA512"

Example

import RNSimpleCrypto from "react-native-simple-crypto";

// -- AES ------------------------------------------------------------- //
const message = "data to encrypt";
const messageBuffer = RNSimpleCrypto.utils.convertUtf8ToArrayBuffer(message);
const key = await RNSimpleCrypto.utils.randomBytes(16);
const iv = await RNSimpleCrypto.utils.randomBytes(16);

const cipherText = await RNSimpleCrypto.AES.encrypt(messageBuffer, key, iv);
const decrypted = await RNSimpleCrypto.AES.decrypt(cipherText, key, iv);
console.log(RNSimpleCrypto.utils.convertArrayBufferToUtf8(decrypted)); // "data to encrypt"

// -- SHA ------------------------------------------------------------- //
const sha256 = await RNSimpleCrypto.SHA.sha256("test");

// -- HMAC ------------------------------------------------------------ //
const hmacKey = await RNSimpleCrypto.utils.randomBytes(32);
const signature = await RNSimpleCrypto.HMAC.hmac256(messageBuffer, hmacKey);

// -- PBKDF2 ---------------------------------------------------------- //
const derivedKey = await RNSimpleCrypto.PBKDF2.hash("password", "salt", 4096, 32, "SHA1");

// -- RSA ------------------------------------------------------------- //
const rsaKeys = await RNSimpleCrypto.RSA.generateKeys(2048);
const encrypted = await RNSimpleCrypto.RSA.encrypt(message, rsaKeys.public);
const decryptedRsa = await RNSimpleCrypto.RSA.decrypt(encrypted, rsaKeys.private);

const sig = await RNSimpleCrypto.RSA.sign(message, rsaKeys.private, "SHA256");
const valid = await RNSimpleCrypto.RSA.verify(sig, message, rsaKeys.public, "SHA256");

Running E2E Tests

The test suite uses a React Native example app with Maestro for E2E testing. Tests cover AES, SHA, HMAC, PBKDF2, RSA, and utility functions (22+ assertions).

Prerequisites

curl -Ls "https://get.maestro.mobile.dev" | bash

Setup

# Install library dependencies (needed for base64-js)
npm install

# Install example app dependencies
cd example
npm install
cd ios && bundle exec pod install && cd ..

Run

# Terminal 1: Start Metro
cd example
npx react-native start --reset-cache

# Terminal 2: Build and run the app on simulator
cd example
npx react-native run-ios --simulator="iPhone 16 Pro"

# Terminal 3: Run Maestro tests (once the app is loaded)
maestro test maestro/flows/run_all_tests.yaml

You can also run individual test modules:

maestro test maestro/flows/aes_tests.yaml
maestro test maestro/flows/sha_tests.yaml
maestro test maestro/flows/hmac_tests.yaml
maestro test maestro/flows/pbkdf2_tests.yaml
maestro test maestro/flows/rsa_tests.yaml
maestro test maestro/flows/utils_tests.yaml

Forked Libraries