I'm writing some code to encrypt data from a flutter client and send it to our servers. We are using PKCS1 padded RSA but i get the error below when attempting to encrypt the data.
I/flutter (12394): Bad state: Reflectable has not been initialized.
I/flutter (12394): Please make sure that the first action taken by your program
I/flutter (12394): in `main` is to call `initializeReflectable()`.
The code responsible for this is as follows.
static String encrypt(String text, RSAPublicKey pubKey) {
var cipher = PKCS1Encoding(RSAEngine());
cipher.init(true, PublicKeyParameter<RSAPublicKey>(pubKey));
Uint8List output1 = cipher.process(utf8.encode(text));
return base64Encode(output1);
}
I've managed to get a non padded sample running fine but the PKCS1 padded encryption requires a random generator that is initialized through reflection and flutter is saying no.
Any help would be appreciated.