Android DES encrypt desEncodeECB(byte[] key, byte[] data)

Here you can find the source of desEncodeECB(byte[] key, byte[] data)

Description

des Encode ECB

Declaration

public static byte[] desEncodeECB(byte[] key, byte[] data)
        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;

public class Main {

    public static byte[] desEncodeECB(byte[] key, byte[] data)
            throws Exception {
        Key deskey = null;//from w  ww.j a  v  a  2  s.co m
        DESedeKeySpec spec = new DESedeKeySpec(key);
        SecretKeyFactory keyfactory = SecretKeyFactory
                .getInstance("desede");
        deskey = keyfactory.generateSecret(spec);
        Cipher cipher = Cipher.getInstance("desede" + "/ECB/NoPadding");
        cipher.init(Cipher.ENCRYPT_MODE, deskey);
        byte[] bOut = cipher.doFinal(data);
        return bOut;
    }
}

Related

  1. encode(String key, String data)
  2. desEncodeCBC(byte[] key, byte[] keyiv, byte[] data)
  3. decrypt(String property)
  4. encrypt(String property)
  5. encryptDES(String encryptString, String encryptKey)
  6. encryptDESFile(byte[] encryptdata, String encryptKey)