zoukankan      html  css  js  c++  java
  • DES加密解密

        /// <summary>
        /// 字符串加密解密类
        /// </summary>
        public sealed class StringSecurity
        {
            private StringSecurity() { }
    
            #region DES 加密/解密
    
            private static byte[] key = ASCIIEncoding.ASCII.GetBytes("uiertysd");
            private static byte[] iv = ASCIIEncoding.ASCII.GetBytes("99008855");
    
            /// <summary>
            /// DES加密。
            /// </summary>
            /// <param name="inputString">输入字符串。</param>
            /// <returns>加密后的字符串。</returns>
            public static string DESEncrypt(string inputString)
            {
                MemoryStream ms = null;
                CryptoStream cs = null;
                StreamWriter sw = null;
    
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                try
                {
                    ms = new MemoryStream();
                    cs = new CryptoStream(ms, des.CreateEncryptor(key, iv), CryptoStreamMode.Write);
                    sw = new StreamWriter(cs);
                    sw.Write(inputString);
                    sw.Flush();
                    cs.FlushFinalBlock();
                    return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
                }
                finally
                {
                    if (sw != null) sw.Close();
                    if (cs != null) cs.Close();
                    if (ms != null) ms.Close();
                }
            }
    
            /// <summary>
            /// DES解密。
            /// </summary>
            /// <param name="inputString">输入字符串。</param>
            /// <returns>解密后的字符串。</returns>
            public static string DESDecrypt(string inputString)
            {
                MemoryStream ms = null;
                CryptoStream cs = null;
                StreamReader sr = null;
    
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                try
                {
                    ms = new MemoryStream(Convert.FromBase64String(inputString));
                    cs = new CryptoStream(ms, des.CreateDecryptor(key, iv), CryptoStreamMode.Read);
                    sr = new StreamReader(cs);
                    return sr.ReadToEnd();
                }
                finally
                {
                    if (sr != null) sr.Close();
                    if (cs != null) cs.Close();
                    if (ms != null) ms.Close();
                }
            }
  • 相关阅读:
    3.6 批量维护来源准则/查看来源准则
    3.5 供货比例(来源准则)控制
    3.4 新供应商引入
    3.3 集团化采购管理
    3.2 采购管理目标
    3.1 采购管理规划
    2.8 生产辅料管理
    2.7 车间任务的批量移动和批量完工入库
    2.6 自动更新车间任务的供应类型和完工子库
    2.5 总装与部装跟单任务的同步发放
  • 原文地址:https://www.cnblogs.com/xiaowie/p/8664059.html
Copyright © 2011-2022 走看看