C# 常用方法——32位MD5加密

其他常用方法详见:https://www.cnblogs.com/zhuanjiao/p/12060937.html

        /// <summary>
		/// 32位MD5加密(小写)
		/// </summary>
		/// <param name="input">输入字段</param>
		/// <returns></returns>
		public string Encrypt(string str)
		{
			MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
			byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(str));
			StringBuilder sBuilder = new StringBuilder();
			for (int i = 0; i < data.Length; i++)
			{
				sBuilder.Append(data[i].ToString("x2"));//转化为小写的16进制
			}
			return sBuilder.ToString();
		}

  

 

posted @ 2019-12-24 17:34  煮不熟的鸭子  阅读(2201)  评论(0编辑  收藏  举报