margelo / react-native-quick-crypto

⚡️ A fast implementation of Node's `crypto` module written in C/C++ JSI
Other
692 stars 83 forks source link

Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11 #238

Closed martmalo closed 1 month ago

martmalo commented 6 months ago

I encountrd this error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11

I used Crypto.createDiffieHellman(...) and it worked perfectly, but when I tried Crypto.createDiffieHellman(...).generateKeys() then I got error above.

versions:

"expo": "~49.0.13"
"react-native": "0.72.6"
"react-native-quick-base64": "^2.0.8"
"react-native-quick-crypto": "^0.6.1"

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo', 'module:metro-react-native-babel-preset'],
    plugins: [
      [
        'module-resolver',
        {
          root: ['./'],
          alias: {
            '@': './src',
            '@env': './src/core/env.js',
            crypto: 'react-native-quick-crypto',
            stream: 'stream-browserify',
            buffer: '@craftzdog/react-native-buffer',
          },
          extensions: [
            '.ios.ts',
            '.android.ts',
            '.ts',
            '.ios.tsx',
            '.android.tsx',
            '.tsx',
            '.jsx',
            '.js',
            '.json',
          ],
        },
      ],
      ['nativewind/babel', { mode: 'compileOnly' }],
      'react-native-reanimated/plugin',
    ],
  };
};
boorad commented 1 month ago

createDiffieHellman() is not yet implemented in this library. I think you were probably falling back to that function in crypto-browserify which has been removed from this library.

See implementation-coverage.md for status.