randomBytes for react-native
Go to file
Arik Sosman 31c3704264 IT WORKS! 2016-01-12 18:29:05 -08:00
RNRandomBytes.xcodeproj Initial commit 2015-11-19 19:50:48 +00:00
RNRandomBytesTests Initial commit 2015-11-19 19:50:48 +00:00
.gitignore Initial commit 2015-11-19 19:50:48 +00:00
LICENSE Initial commit 2015-11-19 19:50:48 +00:00
README.md add README 2015-11-19 20:09:49 +00:00
RNRandomBytes.h Initial commit 2015-11-19 19:50:48 +00:00
RNRandomBytes.m Initial commit 2015-11-19 19:50:48 +00:00
index.js IT WORKS! 2016-01-12 18:29:05 -08:00
package.json IT WORKS! 2016-01-12 18:29:05 -08:00

README.md

react-native-randombytes

Usage

Note: only the asynchronous API is supported, due to the limitations of having to go over the RCTBridge, and there being no secure RNG in JavaScriptCore (Math.random is a bit of a joke in the industry)

var randomBytes = require('react-native-randombytes')
randomBytes(4, (err, bytes) => {
  console.log(bytes.toString('hex'))
})

Installation

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