荒草燃烧

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

MD5方法:

public static string GetMD5(string sDataIn)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] bytValue, bytHash;
            bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
            bytHash = md5.ComputeHash(bytValue);
            md5.Clear();
            string sTemp = "";
            for (int i = 0; i < bytHash.Length; i++)
            {
                sTemp += bytHash[i].ToString("X").PadLeft(2, '0');
            }
            return sTemp.ToLower();
        }

密码加盐
        public static string GetPasswordSalt()
        {
            string getPasswordSalt= ConfigurationManager.AppSettings["passwordSalt"];
            return getPasswordSalt;
        }

passwordSalt就是所谓的盐,其内容存放在App.config文件里,app中代码:

<configuration>
  <appSettings>
    <add key="passwordSalt" value="1234"/>//1234为盐,用参数passwordSalt表示
  </appSettings>
</configuration>

posted on 2015-04-25 15:15  王大仙¥  阅读(332)  评论(0编辑  收藏  举报