企业微信 会话内容存档 RSA 解密问题:too much data for RSA block public static String decryptRSA(String str, String privateKey) throws Exception { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); Cipher rsa = Cipher.getInstance("RSA/ECB/PKCS1Padding", "BC"); rsa.init(Cipher.DECRYPT_MODE, getPrivateKey(privateKey)); byte[] utf8 = Base64.decodeBase64(str); System.out.println(utf8); utf8 = rsa.doFinal(utf8); String result = new String(utf8,"UTF-8"); return result; } public static PrivateKey getPrivateKey (String privateKey) throws Exception { Reader privateKeyReader = new StringReader(privateKey); PEMParser privatePemParser = new PEMParser(privateKeyReader); Object privateObject = privatePemParser.readObject(); if (privateObject instanceof PEMKeyPair) { PEMKeyPair pemKeyPair = (PEMKeyPair) privateObject; JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC"); PrivateKey privKey = converter.getPrivateKey(pemKeyPair.getPrivateKeyInfo()); return privKey; } return null; }
企业微信 会话内容存档 RSA 解密问题能不能提供一个解密的 Java 版 demo? 怎么解密都不对~~~~~~~
2022-09-08你这个解决了吗?同问
会话内容存档解密为啥报too much data for RSA block?java.lang.ArrayIndexOutOfBoundsException: too much data for RSA block 在做会话内容存档的时候遇到了这个bug一直无法解决。 byte[] result = rsa.doFinal(Base64.decodeBase64(str)); 解密的前期工作都通过了,就最后一步解密这里出了问题
2022-09-08