content: package com.cjj.mousepaint.utils;
  
  import android.util.Base64;
  
  import javax.crypto.Cipher;
  import javax.crypto.SecretKey;
  import javax.crypto.SecretKeyFactory;
  import javax.crypto.spec.DESKeySpec;
  import javax.crypto.spec.IvParameterSpec;
  
  /**
   * Created by Administrator on 2015/5/15.
   */
  public class DESutils {
  
      private final static String key = "zhbaodai";
      private final static String iv = "12345678";
  
      public static String EncryptDES(String message)
              throws Exception {
          Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
  
          DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
  
          SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
          SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
          IvParameterSpec secretIv= new IvParameterSpec(iv.getBytes("UTF-8"));
          cipher.init(Cipher.ENCRYPT_MODE, secretKey, secretIv);
  
          return  Base64.encodeToString(cipher.doFinal(message.getBytes("UTF-8")), Base64.DEFAULT);
      }
  }
  