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

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

Description

encrypt

Declaration

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

Method Source Code

//package com.java2s;

import javax.crypto.Cipher;

import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

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

    private static byte[] encrypt(byte[] key, byte[] src) throws Exception {
        IvParameterSpec zeroIv = new IvParameterSpec(iv);
        SecretKeySpec spec = new SecretKeySpec(key, "DES");
        Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, spec, zeroIv);
        return cipher.doFinal(src);
    }/*from w ww  .  j ava  2s  .  co  m*/
}

Related

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