#region 加密&解密
        /// <summary>
        /// DES对称加密方法
        /// </summary>
        /// <param name="InitData">原始待加密数据</param>
        /// <param name="SecretKey">加密密钥</param>
        public static string EncryptData(object InitData, string SecretKey)
        {
            try
            {
                string newSecretKey = Utils.MD5(SecretKey + MySecretKey).Substring(16, 8);
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                //把字符串放到byte数组中    
                Byte[] inputByteArray = Encoding.Default.GetBytes(InitData.ToString());
                //建立加密对象的密钥和偏移量
                des.Key = ASCIIEncoding.ASCII.GetBytes(newSecretKey);
                //原文使用ASCIIEncoding.ASCII方法的GetBytes方法 
                des.IV = ASCIIEncoding.ASCII.GetBytes(newSecretKey);
                //使得输入密码必须输入英文文本
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                StringBuilder ret = new StringBuilder();
                foreach (Byte b in ms.ToArray())
                {
                    ret.AppendFormat("{0:X2}", b);
                }
                ret.ToString();
                return ret.ToString();
            }
            catch
            {
                return "";
            }
        }

        /// <summary>
        /// DES对称解密方法
        /// </summary>
        /// <param name="EncryptedData">待解密数据</param>
        /// <param name="SecretKey">解密密钥</param>
        public static string DecryptData(object EncryptedData, string SecretKey)
        {
            try
            {
                string newSecretKey = Utils.MD5(SecretKey + MySecretKey).Substring(16, 8);
                string pToDecrypt = EncryptedData.ToString();
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                Byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
                for (int x = 0; x < pToDecrypt.Length / 2; x++)
                {
                    int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
                    inputByteArray[x] = (byte)i;
                }
                //建立加密对象的密钥和偏移量,此值重要,不能修改 
                des.Key = ASCIIEncoding.ASCII.GetBytes(newSecretKey);
                des.IV = ASCIIEncoding.ASCII.GetBytes(newSecretKey);
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                return System.Text.Encoding.Default.GetString(ms.ToArray());
            }
            catch
            {
                return "";
            }
        }
        #endregion

 Utils.MD5(SecretKey + MySecretKey).Substring(16, 8);

这里的MD5自己写一个,然后随意截取其中8位,MySecretKey=内部密钥

Created with the Personal Edition of HelpNDoc: Full-featured Help generator