Fastest Scrypt library for React Native, supporting new architecture and using nitromodules for blazingly fast performance.
This library does not reimplement Scrypt, but instead simply binds Scrypt from CryptoSwift (iOS) & BouncyCastle (Android).
import {Scrypt} from 'react-native-turbo-scrypt';
const passwordString = 'password';
const passwordBuffer = new TextEncoder().encode(passwordString).buffer;
const saltString = 'salt';
const saltBuffer = new TextEncoder().encode(saltString).buffer;
const hex = Scrypt.scrypt(
passwordBuffer, // password: buffer
saltBuffer, // salt: buffer
32768, // N: number
8, // r: number
1, // p: number
32, // key length: number
);
The result is a buffer.
$ bun i react-native-turbo-scrypt
Testing on an iPhone 13 Pro Max, compared to @noble/hashes
js implementation of Scrypt, we are able to achieve a 18.5s time saving with the params in the usage example. Typically in release mode, Scrypt.scrypt() takes around 150-180ms on an iPhone 13 Pro Max. On a Samsung S24 Ultra, we observe typical times of 400-500ms.
NOTICE:
We are aware of an issue on iOS devices, where in Debug apps, Scrypt.scrypt()
takes approx 3-4s instead of the expected 150ms performance. This may be due to the lack of Whole-Module optimisation on debug builds. We would appreciate pull request fixing this issue.