Skip to content Skip to sidebar Skip to footer

Android Encryption Rsa Invalidkeyexception

Dears, I need help to understand why decryptString doesn't work and throw 'java.security.InvalidKeyException: Need RSA private or public key'. When call encrypt method, i use publ

Solution 1:

Try omitting the cipher provider:

Cipheroutput= Cipher.getInstance("RSA/ECB/PKCS1Padding");

Secondly, you can instantiate the provider first to make sure that works, then pass it along as the second argument to Cipher.getInstance(). The second argument can be either a String (provider name) or a Provider (object). Using the second might make debugging easier.

Post a Comment for "Android Encryption Rsa Invalidkeyexception"