zoukankan      html  css  js  c++  java
  • md5 加密

    public static string StringToMD5Hash(string inputString)

    {

    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

    byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(inputString));

    StringBuilder sb = new StringBuilder();

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

    {

    sb.AppendFormat("{0:x2}", encryptedBytes[i]);

    }

    return sb.ToString();

    }

    2
    /// <summary>
    /// md5加密
    /// </summary>
    /// <param name="content"></param>
    /// <returns></returns>
    public static string GetMD5(string content)
    {
    string EncryptString = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(content, "MD5");
    return EncryptString;
    }

    ============================================

    // <summary>
    /// MD5加密
    /// </summary>
    /// <param name="password"></param>
    /// <returns></returns>
    public static string EncryptMD5(string password)
    {
    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] data = System.Text.Encoding.UTF8.GetBytes(password);
    byte[] md5data = md5.ComputeHash(data);
    md5.Clear();
    string str = "";
    for (int i = 0; i < md5data.Length-1; i++)
    {
    str += md5data[i].ToString("x").PadLeft(2, '0');
    }
    return str;
    }

    public static string Md5Hex(string data)
    {
    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
    byte[] dataHash = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
    StringBuilder sb = new StringBuilder();
    foreach (byte b in dataHash)
    {
    sb.Append(b.ToString("x2").ToLower());
    }
    return sb.ToString();
    }

  • 相关阅读:
    关于vs的网站发布
    gaga...
    将gridView中的数据导出 并保存到excel中
    ASP.NET 2.0 Treeview Checkboxes Check All Javascript
    写一个自动编号的存储过程
    获取一个部门的所有下级部门
    相同则写入组合
    jquery html form
    repeater合并单元格
    VS2010 快捷键大全
  • 原文地址:https://www.cnblogs.com/zhang-wenbin/p/6743423.html
Copyright © 2011-2022 走看看