using System.Security.Cryptography;
需要引用这个命名空间
MD5 md = new MD5CryptoServiceProvider();
string source = "aiawaysrain";
byte[] s = Encoding.Default.GetBytes(source);
byte[] output = md.ComputeHash(s);
string outstring = BitConverter.ToString(output).Replace("-","").ToUpper();
Console.Write(outstring);
Console.Read();
输出结果:9118BFD94A9CE9CF37AE5BAA947ED596