amitaymolko / react-native-rsa-native

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

How to test code using this library? #160

Open kodzonko opened 10 months ago

kodzonko commented 10 months ago

generating keys and encryption/decryption seem to work for me in React Native environment but fail when I run these functions in jest unit tests:

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

const encrypted = await RSA.encrypt("test", <RSA public key I generated on device>);
const decrypted = await RSA.decrypt(encrypted, <RSA private key I generated on device>);

example error:

Cannot read properties of undefined (reading 'encrypt')

Also generating keys on PC doesn't work (same error - properties of undefined).

How do I test code that involves react-native-rsa-native? Is it even possible or do I need to patch these functions to run on a computer?