using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; namespace IStation.Untity { public class Md5Cryption { /// /// 32位MD5加密 /// /// 需要加密的文本 /// 加密的编码 public static string Encrypt32(string msg, Encoding encoding = null) { using (MD5 mi = MD5.Create()) { if (encoding == null) encoding = Encoding.UTF8; byte[] buffer = encoding.GetBytes(msg); //开始加密 byte[] newBuffer = mi.ComputeHash(buffer); StringBuilder sb = new StringBuilder(); for (int i = 0; i < newBuffer.Length; i++) { sb.Append(newBuffer[i].ToString("x2")); } return sb.ToString(); } } } }