安卓RSA踩坑第一弹
问题:解密出现了乱码
首先是Base64的问题,编码问题,解析问题。
然后才是RSA,和后台是不一样的,不能直接使用,代码如下。
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, priKey);
cache = cipher.doFinal(inputByte);