C# MD5

 1         private string GetMD5(string sDataIn)
 2         {
 3             MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
 4             byte[] bytValue, bytHash;
 5             bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
 6             bytHash = md5.ComputeHash(bytValue);
 7             md5.Clear();
 8             StringBuilder sTemp = new StringBuilder(sDataIn.Length);
 9             for (int i = 0; i < bytHash.Length; i++)
10             {
11                 sTemp.Append(bytHash[i].ToString("X").PadLeft(2, '0'));
12             }
13             return sTemp.ToString().ToLower();
14         }

 

posted @ 2017-08-25 07:46  乁卬杨  阅读(334)  评论(0编辑  收藏  举报