Android Encryption RSA InvalidKeyException

后端 未结 1 913
悲&欢浪女
悲&欢浪女 2021-02-11 03:16

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 meth

相关标签:
1条回答
  • 2021-02-11 03:37

    Try omitting the cipher provider:

    Cipher output = 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.

    0 讨论(0)
提交回复
热议问题