错误:javax.crypto.BadPaddingException: Blocktype ...
引用:
Afters some hours of trying, confirming that the key pairs are the same, using different options of saving the public key in the Android filesystem, etc. I finally found a post stating that Android is using the Bouncycastle Security provider. Bouncycastle’s default RSA implementation is: “RSA/None/NoPadding”, whereas Sun’s default security provider implementation is “RSA/None/PKCS1Padding”. So, no decryption possible when just using
Cipher.getInstance("RSA")
because of the different paddings used.
So for a solution I downloaded the bouncycastle Jar, added bounycastle as a Security provider to my Java App, and now use
Cipher.getInstance("RSA", "BC");
It works fine now.