Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Howto use getRandomValues in production? #10

Open
aschrijver opened this issue Jul 25, 2017 · 0 comments
Open

Howto use getRandomValues in production? #10

aschrijver opened this issue Jul 25, 2017 · 0 comments

Comments

@aschrijver
Copy link

aschrijver commented Jul 25, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant