/************************************************************
    Function:       // DES_EN(byte[] src,byte[] key)
    Description:    // DES加密算法
    Input:          // byte[] src加密源,byte[] key加密秘钥
    Output:         // 加密后的src
    Return:         // byte[]
  *************************************************************/
        public static byte[] DES_EN(byte[] src, byte[] key) {
        try {
            SecretKey deskey = new SecretKeySpec(key, "DES"); // 生成密钥21
            Cipher c1 = Cipher.getInstance("DES/CBC/NoPadding"); // 实例化负责加密/解密的Cipher工具类22
            c1.init(Cipher.ENCRYPT_MODE, deskey, iv); // 初始化为加密模式23
            return c1.doFinal(src);
        } catch (java.security.NoSuchAlgorithmException e1) {
            e1.printStackTrace();
        } catch (javax.crypto.NoSuchPaddingException e2) {
            e2.printStackTrace();
        } catch (java.lang.Exception e3) {
            e3.printStackTrace();
        }
        return null;
    }

/************************************************************
        Function:       // DES_DE(byte[] src,byte[] key)
        Description:    // DES解密算法
        Input:          // byte[] src解密源,byte[] key解密秘钥
        Output:         // 解密后的src
        Return:         // byte[]
      *************************************************************/
    public static byte[] DES_DE(byte[] src, byte[] key) {
    try {
        SecretKey deskey = new SecretKeySpec(key, "DES");
        Cipher c1 = Cipher.getInstance("DES/CBC/NoPadding");
        c1.init(Cipher.DECRYPT_MODE, deskey, iv); // 初始化为解密模式44
        return c1.doFinal(src);
    } catch (java.security.NoSuchAlgorithmException e1) {
        e1.printStackTrace();
    } catch (javax.crypto.NoSuchPaddingException e2) {
        e2.printStackTrace();
    } catch (java.lang.Exception e3) {
        e3.printStackTrace();
    }
    return null;
}
/************************************************************
       Function:       // encryptMode(byte[] src,byte[] key)
       Description:    // 3DES_CBC_EN
       Input:          // src-源数据(byte[]) key-加密秘钥(byte[])
       Output:         // 加密后的数据
       Return:         // byte[]
     *************************************************************/
       public static byte[] encryptMode(byte[] src, byte[] key) {
       try {
           System.out.println("没到8bytes:" + Util.byteArrayToHexString(src));
           SecretKey deskey = new SecretKeySpec(key, Algorithm); // 生成密钥21
           Cipher c1 = Cipher.getInstance("DESede/CBC/NoPadding"); // 实例化负责加密/解密的Cipher工具类22
           c1.init(Cipher.ENCRYPT_MODE, deskey, iv); // 初始化为加密模式23
           return c1.doFinal(src);
       } catch (java.security.NoSuchAlgorithmException e1) {
           e1.printStackTrace();
       } catch (javax.crypto.NoSuchPaddingException e2) {
           e2.printStackTrace();
       } catch (java.lang.Exception e3) {
           e3.printStackTrace();
       }
       return null;
   }
/***********************************************************************
         * Function: // decryptMode(byte[] src,byte[] key) Description: //
         * 3DES_CBC_DE Input: // src-源数据(byte[]) key-解密秘钥(byte[]) Output: //
         * 解密后的数据 Return: // byte[]
         **********************************************************************/
        public static byte[] decryptMode(byte[] src, byte[] key) {
        try {
            SecretKey deskey = new SecretKeySpec(key, Algorithm);
            Cipher c1 = Cipher.getInstance("DESede/CBC/NoPadding");
            c1.init(Cipher.DECRYPT_MODE, deskey, iv); // 初始化为解密模式44
            return c1.doFinal(src);
        } catch (java.security.NoSuchAlgorithmException e1) {
            e1.printStackTrace();
        } catch (javax.crypto.NoSuchPaddingException e2) {
            e2.printStackTrace();
        } catch (java.lang.Exception e3) {
            e3.printStackTrace();
        }
        return null;
    }
//=========================RSA公钥加密=================================
public static String rsa_pk_encrypt(byte[] data)
{
      
    byte[] result=null;
      
    PublicKey publicKey=null;
      
     //根据生成的密钥获取,输入
    BigInteger modulus=new BigInteger("107387874390505784524513973877097626636040930323785063417203429329049380012116062713367963534546558364338266011147415609622592361642249862575535940504286965419678075850829850981611449282370578971183932155637562314983750327067652855947799699126317486874317221419492450317503254553770513863888939550973346592793");
    BigInteger publicExponent=new BigInteger("65537");
         
    RSAPublicKeySpec rsaPublicKeySpec=new RSAPublicKeySpec( modulus, publicExponent);
      
    KeyFactory keyFactory = null;     
    try {  
        keyFactory = KeyFactory.getInstance("RSA");
    } catch (NoSuchAlgorithmException e1) {    
        e1.printStackTrace();
    }
      
    try {
        publicKey=keyFactory.generatePublic(rsaPublicKeySpec);
    } catch (InvalidKeySpecException e) {
        e.printStackTrace();
    }
      
      
    try {
        Cipher c1 = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        c1.init(Cipher.ENCRYPT_MODE, publicKey);
        result = c1.doFinal(data); 
    } catch (NoSuchAlgorithmException e) {
          
        e.printStackTrace();
    } catch (NoSuchPaddingException e) {
        e.printStackTrace();
    } catch (InvalidKeyException e) {
        e.printStackTrace();
    } catch (IllegalBlockSizeException e) {
        e.printStackTrace();
    } catch (BadPaddingException e) {
        e.printStackTrace();
    }
      
    return dumpByte(result, result.length);
      
}