Installations
npm install react-native-randombytes
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.16.3
NPM Version
6.14.4
Score
94.6
Supply Chain
98.8
Quality
80.5
Maintenance
100
Vulnerability
99.3
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
C# (44.12%)
Java (21.47%)
Objective-C (15.64%)
JavaScript (12.75%)
Ruby (6.02%)
Developer
mvayngrib
Download Statistics
Total Downloads
5,873,816
Last Day
4,375
Last Week
21,274
Last Month
95,251
Last Year
1,119,044
GitHub Statistics
82 Stars
68 Commits
95 Forks
5 Watching
2 Branches
20 Contributors
Bundle Size
25.05 kB
Minified
8.94 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.6.1
Package Id
react-native-randombytes@3.6.1
Size
24.83 kB
NPM Version
6.14.4
Node Version
12.16.3
Publised On
22 Apr 2021
Total Downloads
Cumulative downloads
Total Downloads
5,873,816
Last day
-16.4%
4,375
Compared to previous day
Last week
-15.9%
21,274
Compared to previous week
Last month
7.5%
95,251
Compared to previous month
Last year
-3.7%
1,119,044
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
react-native-randombytes
Usage
1import { randomBytes } from 'react-native-randombytes' 2 3// synchronous API 4// uses SJCL 5const rand = randomBytes(4) 6 7// asynchronous API 8// uses iOS-side SecRandomCopyBytes 9randomBytes(4, (err, bytes) => { 10 // bytes is a Buffer object 11 console.log(bytes.toString('hex')) 12})
Installation
-
Follow the steps in the next section
-
You have two options depending on your needs:
- if you're trying to get Node.js or browser crypto modules working in React Native, follow the installation workflow in react-native-crypto.
- if you only need asynchronous random bytes generation, and don't care about getting back
Buffer
objects, you can do the following:
1import { NativeModules } from 'react-native' 2const { RNRandomBytes } = NativeModules 3RNRandomBytes.randomBytes(32, (err, bytes) => { 4 // bytes is a base64string 5})
Automatic - Android / iOS (recommended)
1react-native link
Manual
If Automatic installation failed you, dry your tears and read on.
iOS
-
Drag RNRandomBytes.xcodeproj from node_modules/react-native-randombytes into your XCode project.
-
Click on the project in XCode, go to Build Phases, then Link Binary With Libraries and add
libRNRandomBytes.a
Confused? See an example with screenshots here
Android
- Update Gradle Settings
1// file: android/settings.gradle 2... 3 4include ':randombytes', ':app' 5project(':randombytes').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-randombytes/android')
- Update Gradle Build
1// file: android/app/build.gradle 2... 3 4dependencies { 5 ... 6 compile project(':randombytes') 7}
- Register React Package
1... 2import com.bitgo.randombytes.RandomBytesPackage // import 3 4public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { 5 6 private ReactInstanceManager mReactInstanceManager; 7 private ReactRootView mReactRootView; 8 9 @Override 10 protected void onCreate(Bundle savedInstanceState) { 11 super.onCreate(savedInstanceState); 12 mReactRootView = new ReactRootView(this); 13 mReactInstanceManager = ReactInstanceManager.builder() 14 .setApplication(getApplication()) 15 .setBundleAssetName("index.android.bundle") 16 .setJSMainModuleName("index.android") 17 .addPackage(new MainReactPackage()) 18 .addPackage(new RandomBytesPackage()) // register package here 19 .setUseDeveloperSupport(BuildConfig.DEBUG) 20 .setInitialLifecycleState(LifecycleState.RESUMED) 21 .build(); 22 mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", null); 23 setContentView(mReactRootView); 24 } 25... 26
Windows
1react-native link react-native-randombytes
Depending on your project versions and the state of RN-Windows this may not always work. If it does not, a manual installation guide can be found here:
https://github.com/Microsoft/react-native-windows/blob/master/docs/LinkingLibrariesWindows.md
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 14/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 14 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-native-randombytes
@consento/sync-randombytes
Synchronous randombytes function that works in node, the browser & react-native!
@react-native-module/randombytes
implementation of randomBytes for React Native
react-native-randombytes-nodeify
randombytes nodeify for react-native, react-native-randombytes wrapper
react-native-secure-randombytes
randomBytes for react-native