收藏
回答

微信退款通知解析req_info报错?

代码:

public static Map<String, String> decryptMapFromResponseString(String aesKey, String responseString) throws Exception {
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] bt = aesKey.getBytes();
    md.update(bt);
    String strDes = bytes2Hex(md.digest());

    SecretKeySpec key = new SecretKeySpec(strDes.getBytes(), "AES");
    Security.addProvider(new BouncyCastleProvider());
    Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");

    cipher.init(Cipher.DECRYPT_MODE, key);
    byte[] base64ByteArr = Base64.decode(responseString);
    String result = new String(cipher.doFinal(base64ByteArr), "utf-8");
    Map<String, String> map = WXPayUtil.xmlToMap(result);
    return map;
}

报错:

Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters
	at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026)
	at javax.crypto.Cipher.init(Cipher.java:1245)
	at javax.crypto.Cipher.init(Cipher.java:1186)
	at com.hct.lottery.payment.main.pay.weixin.WeixinUtil.decryptMapFromResponseString(WeixinUtil.java:265)
	at com.hct.lottery.payment.main.pay.weixin.WeixinUtil.main(WeixinUtil.java:338)

什么情况呢?查了半天也没查出来问题,唉!

回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签