Android DES encrypt encryptEDE(byte[] key, byte[] src)

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

Description

encrypt EDE

Declaration

private static byte[] encryptEDE(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[] encryptEDE(byte[] key, byte[] src)
            throws Exception {
        Key deskey = null;/*  w  w w  .  j a va2 s .  c  o  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.ENCRYPT_MODE, deskey, ips);
        return cipher.doFinal(src);
    }
}

Related

  1. desEncodeECB(byte[] key, byte[] data)
  2. decrypt(String property)
  3. encrypt(String property)
  4. encryptDES(String encryptString, String encryptKey)
  5. encryptDESFile(byte[] encryptdata, String encryptKey)
  6. encrypt(byte[] key, byte[] src)
  7. encryptToBytes(String key, String src)