amitaymolko / react-native-rsa-native

A native implementation of RSA key generation and encryption/decryption.
MIT License
232 stars 112 forks source link

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeRsaNative.RSA.generateKeys')] #145

Open sharif2008 opened 1 year ago

sharif2008 commented 1 year ago

It does not work with expo-

Errors [Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeRsaNative.RSA.generateKeys')] at src\utils\pki.ts:11:4 in createKeyPairRSA at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:66:31 in at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:124:27 in invoke

StrawberryChocolateFudge commented 1 year ago

I had the same error. It works just fine after I ran npx expo run:android and ejected the native config. No other configuration was needed.

willpiam commented 1 year ago

Any way of doing this without ejecting?

willpiam commented 1 year ago

I had the same error. It works just fine after I ran npx expo run:android and ejected the native config. No other configuration was needed.

Could you share more about how to do this? Thank you!

megothss commented 10 months ago

@StrawberryChocolateFudge thank you so much for the tip! It saved my day.

@willpiam you need to run npx expo prebuild and then run your app using npx expo run:android. Take a backup of the folder before, just in case.

alessandrocapra commented 9 months ago

Is there a way of making it work without ejecting it? In modern Expo, let's say SDK 48/49?

I tried to debug what is actually imported:

import * as RSA from "react-native-rsa-native"

If I log the value of RSA, this is the output:

{"RNRSA": null, "RNRSAKeychain": null, "RSA": null, "RSAKeychain": null, "default": null}

If possible I would like to fix it and submit a PR, if someone can give some guidance

RasVibe commented 9 months ago

Any updates regarding the null issue without ejecting in expo mentioned by @alessandrocapra ?

alessandrocapra commented 9 months ago

I ended up using node-forge instead, it works very well

RasVibe commented 9 months ago

Alright - will look into it. Thanks.