Skip to content

Howto use getRandomValues in production? #10

@aschrijver

Description

@aschrijver

Hi, thanks for ReactNativify!

In global.js#L13 the comment mentions:

// Don't do this in production. You're going to want to patch in
// https://github.com/mvayngrib/react-native-randombytes or similar.
global.crypto = {
  getRandomValues(byteArray) {
    for (let i = 0; i < byteArray.length; i++) {
      byteArray[i] = Math.floor(256 * Math.random());
    }
  },
};

in transformer.js there is:

crypto: 'crypto-browserify',

I have 2 questions related to this:

  1. What is the proper way to patch in react-native-randombytes in production as referred to above?

  2. There is also a react-natvie-crypto by the same author derived from crypto-browserify and using react-native-randombytes. It currently uses rn-nodify, generates a bunch of shim code. Could this be used the ReactNativify way, maybe be a better alternative?

I have asked the second question on the react-native-crypto project as well: https://github.com/mvayngrib/react-native-crypto/issues/16

Thanks.

PS I have also posted this on stackoverflow: https://stackoverflow.com/q/45301900/8295283

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions