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 salt = ConfigurationManager.AppSettings["passwordSalt"];
            return salt;
        }

 

posted @ 2014-10-26 11:47  步子521  阅读(196)  评论(0编辑  收藏  举报