C# · 12月 19, 2021

MD5加密

代码:

using System; System.Collections.Generic; System.Linq; System.Security.Cryptography; System.Text; System.Threading.Tasks;namespace MessageReminder.Utils{ /// <summary> /// MD5加密 </summary> public class MD5Helper { <summary> MD5加密 </summary> <param name=”text”>原文</param> static string Encrypt(string text) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] bArr = md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(text)); StringBuilder sb = StringBuilder(); foreach (byte b in bArr) { sb.Append(b.ToString(“x2”)); } return sb.ToString(); } }}