Back to rankings

margelo/react-native-quick-crypto

TypeScriptcrypto.margelo.com

⚡️ A fast implementation of Node's `crypto` module written in C/C++ JSI

react-nativereactnativecppjsicryptocryptographyencryptiondecryptionmathsweb3ethers
Star Growth
Stars
1.1k
Forks
119
Weekly Growth
Issues
2
4006008001k
Jul 2022Nov 2023Mar 2025Jul 2026
Artifactsnpmnpm install react-native-quick-crypto
README
react-native-quick-crypto

⚡️ react-native-quick-crypto

A fast implementation of Node's crypto module.

Features

Unlike any other current JS-based polyfills, react-native-quick-crypto is written in C/C++ JSI and provides much greater performance - especially on mobile devices. QuickCrypto can be used as a drop-in replacement for your Web3/Crypto apps or CRDT-based local first databases to speed up common cryptography functions.

  • 🏎️ Hundreds of times faster than all JS-based solutions
  • ⚡️ Lightning fast implementation with Nitro Modules (pure C++ and JSI) instead of JS
  • 🧪 Well tested in JS and C++ (OpenSSL)
  • 💰 Made for crypto apps and wallets
  • 🔢 Secure native compiled cryptography
  • 🔁 Easy drop-in replacement for crypto-browserify or react-native-crypto

Versions

Version RN Architecture Modules
1.x new -> Nitro Modules ->
0.x old, new 🤞 Bridge & JSI

Note: Minimum supported version of React Native is 0.75. If you need to use earlier versions, please use 0.x versions of this library.

Migration

Our goal in refactoring to v1.0 was to maintain API compatibility. If you are upgrading to v1.0 from v0.x, and find any discrepancies, please open an issue in this repo.

Benchmarks

There is a benchmark suite in the Example app in this repo that has benchmarks of algorithms against their pure JS counterparts. This is not meant to disparage the other libraries. On the contrary, they perform amazingly well when used in a server-side Node environment. This library exists because React Native does not have that environment nor the Node Crypto API implementation at hand. So the benchmark suite is there to show you the speedup vs. the alternative of using a pure JS library on React Native.


Installation

React Native  

bun add react-native-quick-crypto react-native-nitro-modules react-native-quick-base64
cd ios && pod install

Expo   Expo

expo install react-native-quick-crypto
expo prebuild

Optional: override global.Buffer and global.crypto in your application as early as possible for example in index.js.

import { install } from 'react-native-quick-crypto';

install();

Replace crypto-browserify

If you are using a library that depends on crypto, instead of polyfilling it with crypto-browserify (or react-native-crypto) you can use react-native-quick-crypto for a fully native implementation. This way you can get much faster crypto operations with just a single-line change!

Using metro config

Use the resolveRequest configuration option in your metro.config.js

config.resolver.resolveRequest = (context, moduleName, platform) => {
  if (moduleName === 'crypto') {
    // when importing crypto, resolve to react-native-quick-crypto
    return context.resolveRequest(
      context,
      'react-native-quick-crypto',
      platform,
    )
  }
  // otherwise chain to the standard Metro resolver.
  return context.resolveRequest(context, moduleName, platform)
}

Using babel-plugin-module-resolver

You need to install babel-plugin-module-resolver, it's a babel plugin that will alias any imports in the code with the values you pass to it. It tricks any module that will try to import certain dependencies with the native versions we require for React Native.

yarn add --dev babel-plugin-module-resolver

Then, in your babel.config.js, add the plugin to swap the crypto, stream and buffer dependencies:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
+   [
+     'module-resolver',
+     {
+       alias: {
+         'crypto': 'react-native-quick-crypto',
+         'stream': 'readable-stream',
+         'buffer': 'react-native-quick-crypto',
+       },
+     },
+   ],
    ...
  ],
};

Note: react-native-quick-crypto re-exports Buffer from @craftzdog/react-native-buffer, so you can use either as the buffer alias. Using react-native-quick-crypto ensures a single Buffer instance across your app.

Then restart your bundler using yarn start --reset-cache.

Usage

For example, to hash a string with SHA256 you can do the following:

import QuickCrypto from 'react-native-quick-crypto';

const hashed = QuickCrypto.createHash('sha256')
  .update('Damn, Margelo writes hella good software!')
  .digest('hex');

More details can be found on the documentation.

Limitations

Not all cryptographic algorithms are supported yet. See the implementation coverage document for more details. If you need a specific algorithm, please open a feature request issue and we'll see what we can do.

Community Discord

Join the Margelo Community Discord to chat about react-native-quick-crypto or other Margelo libraries.

Adopting at scale

react-native-quick-crypto was built at Margelo, an elite app development agency. For enterprise support or other business inquiries, contact us at hello@margelo.com!

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

For more detailed guides, check out our documentation website:

License

  • react-native-quick-crypto is licensed under MIT.
  • react-native-quick-crypto is heavily inspired by NodeJS Crypto, which is licensed under nodejs/LICENSE.
Related repositories
react/react-native

A framework for building native applications using React

C++MIT Licenseandroidapp-framework
reactnative.dev
126.2k25.2k
facebook/react-native

A framework for building native applications using React

C++MIT Licenseandroidapp-framework
reactnative.dev
120.9k24.5k
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
storybookjs/storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation

TypeScriptnpmMIT Licensestorybookstyleguide
storybook.js.org
90.6k10.2k
enaqx/awesome-react

A collection of awesome things regarding React ecosystem

reactreact-native
74k7.6k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
laurent22/joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.

TypeScriptnpmOtherreact-nativenodejs
joplinapp.org
55.7k6.2k
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
expo/expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.

TypeScriptnpmMIT Licensemobileexpo
docs.expo.dev
50.9k13.1k
react-hook-form/react-hook-form

📋 React Hooks for form state management and validation (Web + React Native)

TypeScriptnpmMIT Licensetypescriptreact-hooks
react-hook-form.com
44.8k2.5k
sudheerj/reactjs-interview-questions

List of top 500 ReactJS Interview Questions & Answers....Coding exercise questions are coming soon!!

JavaScriptnpmMIT Licensereactjsreact-router
44.7k10.4k
mattermost/mattermost

Mattermost is an open source platform for secure collaboration across the entire software development lifecycle..

TypeScriptnpmOthercollaborationmattermost
mattermost.com
38.5k8.8k