- MD5散列算法(单项加密)
- 必须引入System.Security.Cryptography 命名空间
/// <summary> /// 功能:MD5散列算法 /// </summary> /// <param name="inputStr">参数:待加密的字符串</param> /// <param name="secString">参数:特殊加密字符串</param> /// <returns>返回值:加密后的密文(大写),string类型</returns> public static string GetMd5Str(string inputStr, string secString) { byte[] palinData = null; byte[] encryptData = null; try { MD5 md5 = new MD5CryptoServiceProvider(); palinData = Encoding.Default.GetBytes(inputStr + secString); encryptData = md5.ComputeHash(palinData); } catch (Exception e) { throw e; } return Convert.ToBase64String(encryptData).Substring(0, 20).ToUpper(); }
- 待续......
时间: 2024-11-10 23:27:36