This package provides a port of Node.js's `crypto` module for React Native environments. It is a direct clone of `crypto-browserify` but replaces `randombytes` with a React Native-compatible implementation. The package is currently at version 2.2.1 and has been explicitly *deprecated* by its maintainers. The recommended alternative is to use `react-native-get-random-values` for secure random byte generation in conjunction with `crypto-browserify` directly. `react-native-crypto`'s primary function was to enable common cryptographic operations such as hashing (SHA, MD5), HMACs, PBKDF2 key derivation, and symmetric encryption/decryption (AES) within React Native applications, which inherently lack Node.js core modules. Its integration required a complex setup involving `rn-nodeify` to shim necessary Node.js modules and an explicit `shim.js` import at the application's entry point to function correctly, making its setup prone to errors. Its release cadence was slow, and maintenance has effectively ceased due to the deprecation notice.
npm install react-native-cryptoVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up `react-native-crypto` by importing the `shim.js` and then performing common cryptographic operations like hashing, random byte generation, and PBKDF2 key derivation.
Migrate your implementation to use `react-native-get-random-values` and `crypto-browserify` instead. Ensure proper polyfills are in place for Buffer if needed.
Carefully follow the `rn-nodeify` installation instructions, ensuring you back up your `package.json` before running `--hack`. Be prepared for potential conflicts during upgrades or if other modules also require similar shimming.
Ensure `import './shim.js'` is the absolute first statement in your main application entry file, before any other imports or code.
Always refer to the `react-native-randombytes` documentation for the correct linking procedure based on your React Native version. Incorrect linking will lead to runtime errors related to native modules.
First, ensure `npm i --save-dev rn-nodeify` and then run `./node_modules/.bin/rn-nodeify --hack --install`. Second, verify that `import './shim.js'` is the *first* line in your main application entry file.
Ensure `import './shim.js'` is the absolute first statement in your root `index.js` or platform-specific entry files. Double-check that `rn-nodeify` was run with `--hack --install`.
Follow the linking instructions for `react-native-randombytes` carefully. For React Native >= 0.60, this usually involves `cd ios && pod install` after `npm install`. For older versions, use `react-native link react-native-randombytes`.