{"library":"react-native-crypto","title":"React Native Crypto","description":"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.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-crypto"],"cli":null},"imports":["import crypto from 'crypto'","import { createHash } from 'crypto'","import './shim.js'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import './shim.js';\nimport crypto from 'crypto';\n\n// Example: Hashing data\nconst dataToHash = 'Hello, React Native Crypto!';\nconst hash = crypto.createHash('sha256');\nhash.update(dataToHash);\nconst hashedData = hash.digest('hex');\nconsole.log('SHA256 Hash:', hashedData);\n\n// Example: Generating random bytes\nconst randomBytes = crypto.randomBytes(16);\nconsole.log('Random Bytes (hex):', randomBytes.toString('hex'));\n\n// Example: PBKDF2 key derivation\nconst password = 'mysecretpassword';\nconst salt = crypto.randomBytes(16);\ncrypto.pbkdf2(password, salt, 100000, 64, 'sha512', (err, derivedKey) => {\n  if (err) throw err;\n  console.log('Derived Key (hex):', derivedKey.toString('hex'));\n});","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}