β¨ Written 100% in C++ with β‘ blazing-fast performance and direct bindings to JavaScript! π
Requires new arch to be set to true
- π‘οΈ End-to-end encryption built for speed.
- π Direct bindings with React Native via ultra-efficient C++ integration.
- π± Cross-platform support: Fully optimized for both iOS and Android.
- π₯ Lightweight
- π Supports Both async and sync methods
- π AES-128 and AES-256 support - Choose your encryption strength
- β‘ Blazing fast performance with native C++ implementation
npm install react-native-turbo-encryption
import {
decrypt,
encrypt,
encryptAsync,
decryptAsync,
} from 'react-native-turbo-encryption';
const key = 'mysecurekey12345';
const encryptedResult = encrypt(
'DSP Siraj is the best batsman in the world',
key
);
const encryptedResultAsync = await encryptAsync(
'DSP Siraj is the best batsman in the world',
key
); //Async way
// encryptedResult -> 64672edc4828c8f5f8940715f44a012b90f659a20e46e76cb9731348ea6ff408b60198054da3e49ba3d566634fa122e6
const decryptedResult = decrypt(encryptedResult, key);
const decryptedResultAsync = await decryptAsync(encryptedResultAsync, key); //Async way
// decryptedResult -> "DSP Siraj is the best batsman in the world"
import {
decrypt256,
encrypt256,
encrypt256Async,
decrypt256Async,
} from 'react-native-turbo-encryption';
const key = 'mysecurekey12345';
const encryptedResult = encrypt256(
'DSP Siraj is the best batsman in the world',
key
);
const encryptedResultAsync = await encrypt256Async(
'DSP Siraj is the best batsman in the world',
key
); //Async way
const decryptedResult = decrypt256(encryptedResult, key);
const decryptedResultAsync = await decrypt256Async(encryptedResultAsync, key); //Async way
// decryptedResult -> "DSP Siraj is the best batsman in the world"
Method | Description | Parameters |
---|---|---|
encrypt(plainText, key) |
Encrypt text using AES-128 | plainText: string , key: string |
decrypt(encryptedText, key) |
Decrypt text using AES-128 | encryptedText: string , key: string |
encryptAsync(plainText, key) |
Async encrypt using AES-128 | plainText: string , key: string |
decryptAsync(encryptedText, key) |
Async decrypt using AES-128 | encryptedText: string , key: string |
encrypt256(plainText, key) |
Encrypt text using AES-256 | plainText: string , key: string |
decrypt256(encryptedText, key) |
Decrypt text using AES-256 | encryptedText: string , key: string |
encrypt256Async(plainText, key) |
Async encrypt using AES-256 | plainText: string , key: string |
decrypt256Async(encryptedText, key) |
Async decrypt using AES-256 | encryptedText: string , key: string |
Module Name | Encryption Time (ms) |
---|---|
react-native-turbo-encryption | 5 ms |
react-native-aes-crypto | 30 ms |
Note: react-native-aes-crypto has better security features than this. Prefer using that if security is your top priority.
This module uses the tinyaes C library as a submodule for AES encryption. The library has been modified to support both AES-128 and AES-256 encryption modes.
The tinyaes
submodule has been modified to enable AES-256 support:
- Enabled
AES256
macro incpp/tinyaes/aes.h
- Configured key sizes to support both AES-128 and AES-256
- Added proper key handling for both encryption modes
Note: Since the submodule code has been modified, you may need to handle submodule updates carefully. Consider forking the tinyaes repository if you need to maintain these changes long-term.
Since we've modified the tinyaes
submodule code, here are the recommended approaches:
- Fork the tinyaes repository and point the submodule to your fork
- Document the changes in this README (as done above)
- Create a patch file for the modifications β (done)
- Consider contributing the AES-256 support back to the original tinyaes project
Recommended workflow for future updates:
- Fork the tinyaes repository on GitHub
- Apply the patch to your fork
- Update the submodule to point to your fork
- Test thoroughly to ensure compatibility
This way, you maintain control over the modifications while still being able to receive updates from the original repository.
To track these changes, you can:
# Check the current submodule status
git submodule status
# See what changes have been made to the submodule
cd cpp/tinyaes
git status
git diff
# Commit the submodule changes
git add .
git commit -m "Enable AES-256 support"
A patch file has been created (aes256-support.patch
) that contains the exact changes made to the tinyaes submodule. This can be used to:
- Apply the same changes to future versions of the submodule
- Share the modifications with others
- Document the exact changes made
To apply this patch to a fresh submodule:
cd cpp/tinyaes
git apply ../../aes256-support.patch
The tinyaes submodule is currently at commit 3dec066
with the AES-256 support changes committed. The submodule is in a detached HEAD state, which is normal for submodules.
Current submodule commit: 3dec066e9b9c21aa66d98563b6247d28971d2cc4
Changes: Enabled AES-256 support and configured key sizes for dual AES-128/AES-256 compatibility