//3DES算法,CBC模式无填充方式解密过程
public static String decryptMode( byte[] src) throws Exception {
String decryptByte = null; final String keyBase64 = "Base64编码后的key"; final String ivBase64 = "Base64编码后的iv向量"; byte[] keybyte = getFromBASE64(keyBase64); byte[] ivbyte = getFromBASE64(ivBase64); SecureRandom sr = new SecureRandom(); DESedeKeySpec dks = new DESedeKeySpec(keybyte); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede"); SecretKey securekey = keyFactory.generateSecret(dks); IvParameterSpec iv = new IvParameterSpec(ivbyte); Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, securekey, iv); decryptByte = new String(cipher.doFinal(src),"UTF-8"); return decryptByte; } // 将 BASE64 编码的字符串s 进行解码 public static byte[] getFromBASE64(String s) throws Exception { return (new BASE64Decoder()).decodeBuffer(s); }参考了: