react-native-rsa-native icon indicating copy to clipboard operation
react-native-rsa-native copied to clipboard

null is not an object (Evaluating RSA.generateKeys)

Open ralucaBoyte opened this issue 5 years ago • 11 comments

Do you have an example in Java where you decrypt the message you encrypted with the code below? The key is in PKCS1 format and I can't seem to work this out in Java.

import { RSA } from 'react-native-rsa-native';

let message = "my secret message";
 
RSA.generateKeys(4096) // set key size
.then(keys => {
    console.log('4096 private:', keys.private); // the private key
    console.log('4096 public:', keys.public); // the public key
    RSA.encrypt(message, keys.public)
    .then(encodedMessage => {
        console.log(`the encoded message is ${encodedMessage}`);
        RSA.decrypt(encodedMessage, keys.private)
        .then(decryptedMessage => {
            console.log(`The original message was ${decryptedMessage}`);
        });
    });
});

ralucaBoyte avatar May 16 '20 06:05 ralucaBoyte

Same error! only in ios

Georgge avatar May 26 '20 21:05 Georgge

I'm experiencing the same issue when trying to generate keys on IOS.

This is the object that comes back from const Rsa = require('react-native-rsa-native');:

image

I tried downgrading to the version referenced the docs to no avail. I also tried previous versions that seemed to have worked fine in the past, but now don't.

@amitaymolko any thoughts on why those objects are null in IOS ?

alexanderjeurissen avatar Jul 03 '20 22:07 alexanderjeurissen

Which iOS version? Which RSA Native version? Which React Native version? Also what device are you testing on?

I'll try to recreate

amitaymolko avatar Jul 06 '20 09:07 amitaymolko

Hi @amitaymolko Thanks for replying on such short notice. See the information you requested below:

Which iOS version?

iOS 13.5.1

Which RSA Native version?

I tested the following versions:

  • v1.1.14
  • v2.0.1
  • v1.0.24

Which React Native version?

I'm using expo, resolved at version 37.0.12. which indicates it's using react-native 0.61.4

Also what device are you testing on?

Testing on an iPhone 11 Pro

I'll try to recreate

Thank you so much !!

alexanderjeurissen avatar Jul 06 '20 14:07 alexanderjeurissen

not sure if/how this would work with Expo.
I haven't ever worked with it and it doesn't seem to be straight forward.
You can read up some more about it here: https://docs.expo.io/expokit/expokit/#changing-native-dependencies

amitaymolko avatar Jul 06 '20 15:07 amitaymolko

not sure if/how this would work with Expo. I haven't ever worked with it and it doesn't seem to be straight forward. You can read up some more about it here: https://docs.expo.io/expokit/expokit/#changing-native-dependencies

when reading the docs it does seem that it should be straightforward.

Many libraries in the React Native ecosystem include instructions to run react-native link. These are supported with ExpoKit for iOS. [...]

and

[...] If the library supports CocoaPods (has a .podspec file), just follow the normal instructions and run react-native link.

I don't see mention of the necessity to link react-native link in the README of this project (react-native-rsa-native), however the fact that this project does have a .podspec file should mean that there is no difference with a regular react native stack in this regard.

There are deprecation warnings in the docs you linked however and the “bare workflow” that the documentation links to indicates that “ejecting” from Expo is required. https://docs.expo.io/bare/customizing/

I’ll give ejecting a shot and see if that fixes the issue.

alexanderjeurissen avatar Jul 06 '20 15:07 alexanderjeurissen

@alexanderjeurissen did u manage to fix this problem? I would like to know if it is possible to use Expo with this library

raptox avatar Jan 29 '21 09:01 raptox

@raptox I did not. The project I needed this for is currently on the back burner and if I revisit it I'm strongly considering writing it in Swift / Objective C

alexanderjeurissen avatar Jan 29 '21 21:01 alexanderjeurissen

Seems that this still doesn't work on Expo a year later. Unfortunate

HPaulson avatar Jan 17 '22 22:01 HPaulson

this lib is DEAD

fukemy avatar May 18 '22 10:05 fukemy

I thought this happened to me since I saw a (null) popup in console.log. But it might have been unrelated. My app crashed on IOS because the public key I used didn't have -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- surrounding it.

Dror-Bar avatar Jun 14 '22 08:06 Dror-Bar