Android Encryption RSA InvalidKeyException

后端 未结 1 910
予麋鹿
予麋鹿 2021-02-11 02:50

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:42

    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)
提交回复
热议问题