react-native-csrng
v1.0.1
Published
High-performance, cross-platform library that provides cryptographically secure random bytes for React Native applications.
Downloads
18
Maintainers
Readme
react-native-csrng
High-performance, cross-platform library that provides cryptographically secure random bytes for React Native applications.
Uses SecRandomCopyBytes on iOS and SecureRandom on Android.
Table of Contents
Usage
The library exports 3 functions:
getRandomBytes(length: number) => ArrayBuffer
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)getRandomInt(min: number, max:number) => number
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)generateUUID() => string
Returns a random UUID
import { getRandomInt } from 'react-native-csrng'
const randomUUID = generateUUID()Installation
// Yarn
yarn add react-native-csrng
// NPM
npm install react-native-csrngExample
To 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 startInstall the app:
Android:
// Yarn yarn example android // NPM npm run example androidiOS:
// Yarn yarn example ios // NPM npm run example ios
Contributing
Feel free to dive in! Open an issue or submit PRs.
react-native-csrng follows the Contributor Covenant Code of Conduct.
Contributors
This project exists thanks to all the people who contribute. @Daload
License
MIT © Daload
