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

[TypeError: _reactNativeQuickCrypto.default.generateKey is not a function (it is undefined)] #188

Closed
pawan-pk opened this issue Aug 10, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@pawan-pk
Copy link

I am stuck with _reactNativeQuickCrypto.default.generateKey is not a function (it is undefined)] problem my code is:

Crypto.generateKey('aes', {length: 32}, (err, key) => {
      if (err === null) {
        console.log("Generated key", key);
        reject();
        resolve(key);
      } else {
        console.log('Error is key generation: ', err);
        reject(err);
      }
    });
  });

Help us to find the issues which I am making.

@pawan-pk
Copy link
Author

I am also using react-native-aes-gcm-crypto lib to encrypt file.

@Montchy Montchy added the bug Something isn't working label Aug 14, 2023
@raphaelheinz
Copy link

@pawan-pk Have you found a solution? We are facing the same problem.

@boorad
Copy link
Collaborator

boorad commented Jan 29, 2024

I would be interested to know if #224 fixes this issue.

@boorad
Copy link
Collaborator

boorad commented Feb 7, 2024

@pawan-pk @raphaelheinz the fix may have been merged today. Can you try again?

@raphaelheinz
Copy link

Hi @boorad, thanks a lot for your message. However, I am still facing the same issue after the merge.

Installation
npm install --save https://github.com/margelo/react-native-quick-crypto

Code

import Crypto from 'react-native-quick-crypto';
...
Crypto.generateKey('aes', { length: 32 }, (err, key) => {
      console.log("callback", err, key);
});

Am I am doing something wrong?

@boorad
Copy link
Collaborator

boorad commented Feb 7, 2024

No, that was my bad. I saw that exact same error, but it wasn't for generateKey(), or even subtle.generateKey().

What I fixed was in generateRSAKeyPair(), an internal function. Some tests were broken, and I put key generation inside of the callInvoker here. That ended up fixing the ... is not a function (it is undefined) error I was seeing, but it's not the same as yours.

Your function does not seem to be implemented yet, sady. I started a new file that keeps track of what is implemented in crypto and crypto.subtle but only populated the subtle part, as that's what I'm working on right now.

@raphaelheinz
Copy link

Okay, no problem. Thanks for your feedback.
I found a workaround for my problem anyway. I am not sure how @pawan-pk is doing. I have nothing against closing this issue...

@pawan-pk
Copy link
Author

Yes, I have already fixed my issues using Browserify of node crypto lib and that works for me.
Thanks for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants