微信退款回调解密 pad block corrupted

微信退款回调解密 pad block corrupted,第1张

微信退款回调解密 pad block corrupted,第2张

以下是相关代码

public static String decryptData(String base64Data) throws Exception {
    Security.addProvider(new BouncyCastleProvider());
    Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");
    cipher.init(Cipher.DECRYPT_MODE, key);
    byte[] decode = Base64Util.decode(base64Data);
    return new String(cipher.doFinal(decode));
}

public static byte[] decode(String data) {  
    char ibuf[] = new char[4];  
    int ibufcount = 0;  
    byte obuf[] = new byte[(data.length() / 4) * 3 + 3];  
    int obufcount = 0;  
    for (int i = 0; i < data.length(); i++) {  
        char ch = data.charAt(i);  
        if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127))  
            continue;  
        ibuf[ibufcount++] = ch;  
        if (ibufcount == ibuf.length) {  
            ibufcount = 0;  
            obufcount += decode0(ibuf, obuf, obufcount);  
        }  
    }  

    if (obufcount == obuf.length) {  
        return obuf;  
    }  
    else {  
        byte ret[] = new byte[obufcount];  
        System.arraycopy(obuf, 0, ret, 0, obufcount);  
        return ret;  
    }  
}  

    public static String md5Encode(String origin, String charsetname) {
        String resultString = null;  
        try {  
            resultString = new String(origin);  
            MessageDigest md = MessageDigest.getInstance("MD5");  
            if (charsetname == null || "".equals(charsetname))  
                resultString = byteArrayToHexString(md.digest(resultString.getBytes()));  
            else  
                resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));  
        }  
        catch (Exception exception) {  
        }  
        return resultString;  
    }
----------------------- 以下是精选回复-----------------------

答:java 推荐这个 https://github.com/Wechat-Group/WxJava 全套的微信 SDK
答:微信提供了封装好的 WechatPayHttpClientBuilder,直接用吧

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 微信退款回调解密 pad block corrupted

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情