using System.Security.Cryptography; using System.Text; namespace Opsoft.NetCore.O3App.WebApi { public static class MD5Help { //这样容易解的密码变的更难解=无解 const string MD5Key = "r16TD&*~12{]?[+3"; /// /// /// /// /// public static string MD5Encrypt(string source, string hStrText = MD5Key) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] buffer = md5.ComputeHash(Encoding.UTF8.GetBytes(source)); string strMD5Value = string.Empty; for (int i = 0; i < buffer.Length; i++) { int a = 0xf & buffer[i] >> 4; int b = buffer[i] & 0xf; strMD5Value += hStrText.Substring(a, 1) + hStrText[b];//0xf & buffer[i] >> 4 buffer[i] & 0xf } return strMD5Value; } } }