哥们 你解决了吗
企业微信会话存档解密encryptRandomKey失败解密代码如下: /** * 私钥解密 * * @param ciphertext 被加密字符串 * @return 解密后字符串 */ public static String decryptByPriKey(String ciphertext, String privateKeyStr) { log.info("私钥解密 ciphertext:【{}】,privateKeyStr:【{}】",ciphertext ,privateKeyStr); PrivateKey privateKey = null; try { Reader privateKeyReader = new StringReader(privateKeyStr); PEMParser privatePemParser = new PEMParser(privateKeyReader); Object privateObject = privatePemParser.readObject(); Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); if (privateObject instanceof PEMKeyPair) { PEMKeyPair pemKeyPair = (PEMKeyPair) privateObject; JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC"); privateKey = converter.getPrivateKey(pemKeyPair.getPrivateKeyInfo()); } Cipher rsa = Cipher.getInstance("RSA/ECB/PKCS1Padding", "BC"); rsa.init(Cipher.DECRYPT_MODE, privateKey); byte[] utf8 = rsa.doFinal(Base64.getDecoder().decode(ciphertext)); return new String(utf8, StandardCharsets.UTF_8); } catch (Exception e) { e.printStackTrace(); } return null; } 报错如下: org.bouncycastle.jcajce.provider.util.BadBlockException: unable to decrypt block at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.getOutput(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineDoFinal(Unknown Source) at javax.crypto.Cipher.doFinal(Cipher.java:2164) at com.qdum.workwechat.common.utils.vm.RSAUtils.decryptByPriKey(RSAUtils.java:87) at com.qdum.workwechat.common.utils.vm.WorkMsgBackUpUtil.main(WorkMsgBackUpUtil.java:282) Caused by: org.bouncycastle.crypto.InvalidCipherTextException: block incorrect at org.bouncycastle.crypto.encodings.PKCS1Encoding.decodeBlock(Unknown Source) at org.bouncycastle.crypto.encodings.PKCS1Encoding.processBlock(Unknown Source) ... 5 more 疑问,是什么原因会导致这个问题那,会话存档公钥配置错误?
2022-12-20哥们 解决了吗
企微微信会话存档,mac电脑引用sdk报错求助,该怎么操作 [图片] current system is Mac OS X Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/bomfish/cloudCustomer/cloud-main/src/main/resources/lib/libWeWorkFinanceSdk_Java.so: dlopen(/Users/bomfish/cloudCustomer/cloud-main/src/main/resources/lib/libWeWorkFinanceSdk_Java.so, 1): no suitable image found. Did find: /Users/bomfish/cloudCustomer/cloud-main/src/main/resources/lib/libWeWorkFinanceSdk_Java.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 /Users/bomfish/cloudCustomer/cloud-main/src/main/resources/lib/libWeWorkFinanceSdk_Java.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at com.tencent.wework.Finance.<clinit>(Finance.java:141) at com.xbongbong.cloud.util.WeChatMsgUtilDemo.main(WeChatMsgUtilDemo.java:43)
2022-12-19