MD5加密

---封裝一個用於MD5加密的方法---
public class Safe
{
     public static string ConvertToMD5(string input)
     {
         MD5 md5 = System.Security.Cryptography.MD5.Create();
         byte[] inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
         byte[] hashBytes = md5.ComputeHash(inputBytes);
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i  hashBytes.Length; i++)
         {
             sb.Append(hashBytes[i].ToString(x2));
         }
            return sb.ToString();
     }
}
---使用方法---
string pwd =Safe.ConvertToMD5(model.Pwd + "&#?@*"));


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章