c# 如何计算字符串的md5值

2025-03-20 10:51:50

1、添加引用using System.Security.Cr鲻戟缒男yptography;using System.Text;

2、编写如下代码public static string GetMd5(string text){StringBui造婷用痃lder sb = new StringBuilder();using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()){byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(text));int length = data.Length;for (int i = 0; i < length; i++){sb.Append(data[i].ToString("x2"));}return (sb.ToString());}}

c# 如何计算字符串的md5值
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢