Android DES Decrypt decryptEDE(byte[] key, byte[] src)

Here you can find the source of decryptEDE(byte[] key, byte[] src)

Description

decrypt EDE

Declaration

private static byte[] decryptEDE(byte[] key, byte[] src)
            throws Exception 

Method Source Code

//package com.java2s;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;

public class Main {
    private static byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };

    private static byte[] decryptEDE(byte[] key, byte[] src)
            throws Exception {
        Key deskey = null;//from   w ww .ja v a  2s . co  m
        DESedeKeySpec spec = new DESedeKeySpec(key);
        SecretKeyFactory keyfactory = SecretKeyFactory
                .getInstance("desede");
        deskey = keyfactory.generateSecret(spec);
        Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
        IvParameterSpec ips = new IvParameterSpec(iv);
        cipher.init(Cipher.DECRYPT_MODE, deskey, ips);
        return cipher.doFinal(src);
    }
}

Related

  1. decode(String key, String data)
  2. decode(String key, byte[] data)
  3. decrypt(byte[] key, byte[] src)
  4. encode(String key, String data)
  5. decryptBytes(String key, byte[] src)