java aes解密cbc模式

来源:互联网 发布:弱碱性水的好处 知乎 编辑:程序博客网 时间:2024/06/01 12:42
package com.chinacreator.oa.Aes;




import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;


import sun.misc.BASE64Decoder;


public class DecryptInfo {
//jiemi
  public static String decrypt(String sSrc, String encodingFormat, String sKey, String ivParameter) throws Exception {
        try {
            byte[] raw = sKey.getBytes("ASCII");
            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes());
            cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
            byte[] encrypted1 = new BASE64Decoder().decodeBuffer(sSrc);//先用base64解密
            byte[] original = cipher.doFinal(encrypted1);
            String originalString = new String(original,encodingFormat);
            return originalString;
        } catch (Exception ex) {
            return null;
        }
}

}

需要解密数据:kYt1u99Y%2bx9cIoAq%2bpiEiA%3d%3d

秘钥:时间戳1513842560    

密钥timestamp,请自行在其后补032

秘钥向量:

 200b7ba42d4147a2 

反正我是解不出来 哪位大佬能不能指点一下啊 拜托拜托