public static string Md5(string str) { System.Security.Cryptography.MD5CryptoServiceProvider hashmd5; hashmd5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); return BitConverter.ToString(hashmd5.ComputeHash(System.Text.Encoding.Default.GetBytes(str))).Replace("-", "").ToLower(); }
public string HashTextMD5(string plainString) { if(plainString.Equals(string.Empty)) { return plainString; } MD5CryptoServiceProvider md5=new MD5CryptoServiceProvider(); byte[] btaValue=System.Text.Encoding.UTF8.GetBytes(plainString); byte[] btaHash=md5.ComputeHash(btaValue); md5.Clear(); string strtemp=""; string strtemp2; for(int ii=0;ii<btaHash.Length;ii++) { strtemp2=btaHash[ii].ToString("x").ToUpper(); if(strtemp2.Length<2) { strtemp2="0"+strtemp2; } strtemp=strtemp+strtemp2; } return strtemp; }