11# react-native-csrng
2+
23High-performance, cross-platform library that provides cryptographically secure random bytes for React Native applications.
34Uses ` SecRandomCopyBytes ` on iOS and ` SecureRandom ` on Android.
45
56## Table of Contents
6- - [ Usage] ( #usage )
7- - [ Installation] ( #installation )
8- - [ Example] ( #example )
9- - [ Contributing] ( #contributing )
10- - [ License] ( #license )
7+
8+ - [ Usage] ( #usage )
9+ - [ Installation] ( #installation )
10+ - [ Example] ( #example )
11+ - [ Contributing] ( #contributing )
12+ - [ License] ( #license )
1113
1214## Usage
15+
1316The library exports 3 functions:
17+
1418### getRandomBytes(length: number) => ArrayBuffer
19+
1520Takes a length, the number of bytes to generate, and returns an ArrayBuffer with that length of random bytes.
21+
1622``` javascript
17- import { getRandomBytes } from ' react-native-csrng' ;
23+ import { getRandomBytes } from ' react-native-csrng'
1824
19- const randomArrayBuffer = getRandomBytes (12 );
25+ const randomArrayBuffer = getRandomBytes (12 )
2026```
2127
2228### getRandomInt(min: number, max: number ) => number
29+
2330Takes a min and a max. Returns a random value between those 2 values
31+
2432``` javascript
25- import { getRandomInt } from ' react-native-csrng' ;
33+ import { getRandomInt } from ' react-native-csrng'
2634
27- const randomNumberBetween1And10 = getRandomInt (1 , 10 );
35+ const randomNumberBetween1And10 = getRandomInt (1 , 10 )
2836```
2937
3038### generateUUID() => string
39+
3140Returns a random UUID
41+
3242``` javascript
33- import { getRandomInt } from ' react-native-csrng' ;
43+ import { getRandomInt } from ' react-native-csrng'
3444
35- const randomUUID = generateUUID ();
45+ const randomUUID = generateUUID ()
3646```
3747
3848## Installation
49+
3950``` sh
4051// Yarn
4152yarn add react-native-csrng
4253
4354// NPM
4455npm install react-native-csrng
4556```
57+
4658## Example
59+
4760To run the example, where you can see the library in action you have to run:
61+
48621 . Install dependencies:
63+
4964 ``` sh
5065 // Yarn
5166 yarn example install
5267
5368 //NPM
5469 npm run example install
5570 ```
71+
5672 1. Install Pods for iOS (only needed for iOS):
5773 ` ` ` sh
5874 cd example/ios && pod install && cd ../..
5975 ` ` `
6076
61772. Start Metro Bundler:
78+
6279 ` ` ` sh
6380 // Yarn
6481 yarn example start
6582
6683 // NPM
6784 npm run example start
6885 ` ` `
86+
69873. Install the app:
88+
7089 1. Android:
90+
7191 ` ` ` sh
7292 // Yarn
7393 yarn example android
7494
7595 // NPM
7696 npm run example android
7797 ` ` `
98+
7899 2. iOS:
100+
79101 ` ` ` sh
80102 // Yarn
81103 yarn example ios
@@ -91,9 +113,10 @@ Feel free to dive in! [Open an issue](https://github.com/daload/react-native-csr
91113react-native-csrng follows the [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/) Code of Conduct.
92114
93115# ## Contributors
94- This project exists thanks to all the people who contribute.
116+
117+ This project exists thanks to all the people who contribute.
95118[@Daload](https://github.com/daload)
96119
97120# # License
98121
99- [MIT](LICENSE) © Daload
122+ [MIT](LICENSE) © Daload
0 commit comments