2016-06-13 15:31:25 -04:00
2015-11-19 19:50:48 +00:00
2015-11-19 19:50:48 +00:00
2015-11-19 19:50:48 +00:00
2016-01-13 15:53:44 -08:00
2016-05-01 14:03:31 -04:00
2015-11-19 19:50:48 +00:00
2016-11-09 20:42:00 -05:00
2016-11-10 17:18:04 +01:00
2015-11-19 19:50:48 +00:00
2016-01-23 10:48:27 -05:00
2016-01-13 15:53:44 -08:00

react-native-randombytes

Usage

var randomBytes = require('react-native-randombytes')

// synchronous API
// uses SJCL
var rand = randomBytes(4)

// asynchronous API
// uses iOS-side SecRandomCopyBytes
randomBytes(4, (err, bytes) => {
  console.log(bytes.toString('hex'))
})

Installation

rnpm link

Manual

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
// file: android/settings.gradle
...

include ':randombytes', ':app'
project(':randombytes').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-randombytes/android')
  • Update Gradle Build
// file: android/app/build.gradle
...

dependencies {
    ...
    compile project(':randombytes')
}
  • Register React Package
...
import com.bitgo.randombytes.RandomBytesPackage // import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {

    private ReactInstanceManager mReactInstanceManager;
    private ReactRootView mReactRootView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new RandomBytesPackage()) // register package here
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", null);
        setContentView(mReactRootView);
    }
...

S
Description
randomBytes for react-native
Readme MIT
78 KiB
Languages
C++ 39.8%
Java 25.9%
JavaScript 15.4%
Objective-C 13.7%
CMake 5.2%