| 1234567891011121314151617181920212223242526 | using System;using System.Collections.Generic;using System.Linq;using System.Security.Cryptography;using System.Text;using System.Threading.Tasks;public class MD5Helper{    public static string StrToMD5(string str)    {        MD5 md5 = MD5.Create();        byte[] c = System.Text.Encoding.Default.GetBytes(str);        byte[] b = md5.ComputeHash(c);//用来计算指定数组的hash值        //将每一个字节数组中的元素都tostring,在转成16进制        string newStr = null;        for (int i = 0; i < b.Length; i++)        {            newStr += b[i].ToString("X2");  //ToString(param);//传入不同的param可以转换成不同的效果        }        return newStr;    }}
 |