string str = "要加密的Info"; string pwd = string.Empty; MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); //需要引用命名空间 using System.Security.Cryptography; pwd = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(str)),2,6); //最终 pwd 就是加密后的信息