首页 > 代码库 > MD5加密

MD5加密

public class MD5DEncryptHelper    {        /// <summary>        /// MD5加密        /// </summary>        /// <param name="strText">要加密的内容</param>        /// <returns></returns>        public static string MD5Encrypt(string strText)        {            //MD5 md5 = new MD5CryptoServiceProvider();            //byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(strText));            //string password = string.Empty;            //for (int i = 0; i < result.Length; i++)            //{            //    password += string.Format("{0:x}", result[i]);            //}            //return password;            byte[] result = Encoding.Default.GetBytes(strText);            MD5 md5 = new MD5CryptoServiceProvider();            byte[] output = md5.ComputeHash(result);            var str = BitConverter.ToString(output).Replace("-", "");            return str.ToUpper();        }    }

 

MD5加密