Migration Guide
Moving from legacy libraries to RNQC
If you are coming from react-native-crypto (the slow, standard shim) or expo-crypto, here is how to upgrade.
Why Upgrade?
- Performance: Hundreds of times faster (via C++/JSI).
- Compatibility: Supports modern Node.js 16+ crypto APIs.
- Correctness: Passes the official Node.js test suite.
Migrating from react-native-crypto
react-native-crypto (and rn-nodeify) relies on the React Native Bridge and pure JS fallbacks, which are extremely slow.
Uninstall Legacy Libs
Remove the old shims.
npm uninstall react-native-crypto rn-nodeify react-native-randombytesInstall RNQC
npm install react-native-quick-crypto react-native-nitro-modules
cd ios && pod installGlobal Polyfill (Optional)
If your dependencies (like ethers.js or bitcoinjs-lib) expect crypto to be available globally:
// Top of your entry file
import { install } from 'react-native-quick-crypto';
install(); // Patches global.crypto and global.BufferAlternatively, you can just import crypto from the package directly if you don't want global side-effects:
import crypto from 'react-native-quick-crypto';Migrating from expo-crypto
expo-crypto is a lightweight wrapper around system APIs. It is distinct from Node.js crypto.
| Feature | Expo Crypto | RNQC |
|---|---|---|
| API Style | Crypto.digestStringAsync() | crypto.createHash().update().digest() |
| Streams | ❌ No | ✅ Yes |
| Ciphers | ❌ No (Just Hashing) | ✅ AES, ChaCha20, etc. |
| Sync Methods | ❌ Limited | ✅ Full Support |
If you only need simple hashing (SHA-256), expo-crypto is fine. If you need encryption, decryption, or complex key derivation, you need RNQC.
Code Comparison
Expo Crypto (digest):
import * as Crypto from 'expo-crypto';
const digest = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
'Hello world'
);RNQC (digest):
import { createHash } from 'react-native-quick-crypto';
const digest = createHash('sha256').update('Hello world').digest('hex');