字符串转MD5

 1         public static string Md5Encrypt(string pwd)

 2         {

 3             MD5 md5 = MD5.Create();

 4             byte[] byts = System.Text.Encoding.UTF8.GetBytes(pwd);

 5             byte[] bytsMd5 = md5.ComputeHash(byts);

 6             md5.Clear();//释放类资源,Dispose是释放当前实例资源.

 7             StringBuilder sb = new StringBuilder();

 8             for (int i = 0; i < bytsMd5.Length; i++)

 9             {

10                 sb.Append(bytsMd5[i].ToString("x2"));

11             }

12             return sb.ToString();

13         }

你可能感兴趣的:(字符串)