public static byte[] desTemplate(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) {
        if (data == null || data.length == 0 || key == null || key.length == 0) return null;
        try {
            SecretKeySpec keySpec = new SecretKeySpec(key, algorithm);
            Cipher        cipher  = Cipher.getInstance(transformation);
            SecureRandom  random  = new SecureRandom();
            cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random);
            return cipher.doFinal(data);
        } catch (Throwable e) {
            e.printStackTrace();
            return null;
        }
    }
public static byte [ ] desTemplate ( byte [ ] data , byte [ ] key , String algorithm , String transformation , boolean isEncrypt ) { if ( data == null || data . length == 0 || key == null || key . length == 0 ) return null ; try { SecretKeySpec keySpec = new SecretKeySpec ( key , algorithm ) ; Cipher cipher = Cipher . getInstance ( transformation ) ; SecureRandom random = new SecureRandom ( ) ; cipher . init ( isEncrypt ? Cipher . ENCRYPT_MODE : Cipher . DECRYPT_MODE , keySpec , random ) ; return cipher . doFinal ( data ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; return null ; } }
DES加密模板

@param data           数据
@param key            秘钥
@param algorithm      加密算法
@param transformation 转变
@param isEncrypt      {@code true}: 加密 {@code false}: 解密
@return 密文或者明文，适用于DES，3DES，AES