Here you can find the source of desEncrypt(byte[] data, String encryptKey)
public static byte[] desEncrypt(byte[] data, String encryptKey)
//package com.java2s; //License from project: Apache License import javax.crypto.*; import javax.crypto.spec.DESKeySpec; import java.security.SecureRandom; public class Main { public static byte[] desEncrypt(byte[] data, String encryptKey) { try {/* w ww . j ava2 s . c om*/ SecureRandom sr = new SecureRandom(); DESKeySpec dks = new DESKeySpec(encryptKey.getBytes("UTF-8")); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey key = keyFactory.generateSecret(dks); Cipher cipher = Cipher.getInstance("DES"); cipher.init(Cipher.ENCRYPT_MODE, key, sr); return cipher.doFinal(data); } catch (Exception e) { throw new RuntimeException("Encrypt error"); } } }