I have a problem with RSA encryption and decryption. I am developing in android and would like to get outsourced RSA encryption and decryption. My source code worked well before I tried to outsource it.
I created a private key and a public key and saved it as private.key and public.key. The error is a ClassNotFoundException exception thrown by this method:
public Key getPrivateKey(){ try { InputStream fis = activity.getResources().openRawResource(R.raw.private); ObjectInputStream ois = new ObjectInputStream(fis); Key RSAprivateKey = (Key)ois.readObject(); return RSAprivateKey; } catch (FileNotFoundException e) { Log.e("FileNotFound","FileNotFound"); e.printStackTrace(); } catch (IOException e) { Log.e("IOEXception","IOEXception"); e.printStackTrace(); } catch (ClassNotFoundException e) { Log.e("ClassNotFound","ClassNotFound"); Log.e("Errro", "Error: "+ e.getMessage()); Log.e("error", e.toString()); e.printStackTrace(); } return null; }
I looked at logcat and received this error message:
E/ClassNotFound(1205): ClassNotFound 03-19 13:54:52.176: E/Errro(1205): Error: com.android.org.bouncycastle.jce.provider.JCERSAPrivateCrtKey 03-19 13:54:52.176: E/error(1205): java.lang.ClassNotFoundException: com.android.org.bouncycastle.jce.provider.JCERSAPrivateCrtKey
I hope you understand my problem, because English is not my native language.
Edit: I found out that the problem is not related to code outsourcing. Therefore, I think that the topic can be marked as resolved.
source share