High-performance, cross-platform library that provides cryptographically secure random bytes for React Native applications.
Uses SecRandomCopyBytes on iOS and SecureRandom on Android.
The library exports 3 functions:
Takes a length, the number of bytes to generate, and returns an ArrayBuffer with that length of random bytes.
import { getRandomBytes } from 'react-native-csrng'
const randomArrayBuffer = getRandomBytes(12)Takes a min and a max. Returns a random value between those 2 values
import { getRandomInt } from 'react-native-csrng'
const randomNumberBetween1And10 = getRandomInt(1, 10)Returns a random UUID
import { getRandomInt } from 'react-native-csrng'
const randomUUID = generateUUID()// Yarn
yarn add react-native-csrng
// NPM
npm install react-native-csrngTo run the example, where you can see the library in action you have to run:
-
Install dependencies:
// Yarn yarn example install //NPM npm run example install
- Install Pods for iOS (only needed for iOS):
cd example/ios && pod install && cd ../..
- Install Pods for iOS (only needed for iOS):
-
Start Metro Bundler:
// Yarn yarn example start // NPM npm run example start
-
Install the app:
-
Android:
// Yarn yarn example android // NPM npm run example android
-
iOS:
// Yarn yarn example ios // NPM npm run example ios
-
Feel free to dive in! Open an issue or submit PRs.
react-native-csrng follows the Contributor Covenant Code of Conduct.
This project exists thanks to all the people who contribute. @Daload
MIT ยฉ Daload