c#MD5加密类

 1 using  System;
 2 using  System.Data;
 3 using  System.Configuration;
 4 using  System.Web;
 5 using  System.Web.Security;
 6 using  System.Web.UI;
 7 using  System.Web.UI.WebControls;
 8 using  System.Web.UI.WebControls.WebParts;
 9 using  System.Web.UI.HtmlControls;
10 using  System.Security.Cryptography;
11 using  System.Text;
12
13 ExpandedBlockStart.gifContractedBlock.gif /**/ /// <summary>
14/// kbMd5 的摘要说明
15/// </summary>

16 public   class  kbMd5
17 ExpandedBlockStart.gifContractedBlock.gif {
18    public kbMd5()
19ExpandedSubBlockStart.gifContractedSubBlock.gif    {
20        //
21        // TODO: 在此处添加构造函数逻辑
22        //
23    }

24ContractedSubBlock.gifExpandedSubBlockStart.gif    MD5类的使用#region MD5类的使用
25ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
26    /// 加密方法
27    /// </summary>
28    /// <param name="input">要转换的字符串</param>
29    /// <returns>转换后的MD5</returns>

30
31    public string GetMD5(string input)
32ExpandedSubBlockStart.gifContractedSubBlock.gif    {
33        MD5 md5 = MD5.Create();
34        string result = "";
35        byte[] data = md5.ComputeHash(Encoding.Default.GetBytes(input));
36        for (int i = 0; i < data.Length; i++)
37ExpandedSubBlockStart.gifContractedSubBlock.gif        {
38            result += data[i].ToString("x2");
39        }

40        return result;
41    }

42ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
43    /// MD5比较
44    /// </summary>
45    /// <param name="input">输入的字符串</param>
46    /// <param name="data">比较的字符串</param>
47    /// <returns>是否相同</returns>
48    /// 

49    public bool passWordCheck(string input, string data)
50ExpandedSubBlockStart.gifContractedSubBlock.gif    {
51        string hashInput = GetMD5(input);
52        if (hashInput.Equals(data))
53ExpandedSubBlockStart.gifContractedSubBlock.gif        {
54            return true;
55        }

56        else
57ExpandedSubBlockStart.gifContractedSubBlock.gif        {
58            return false;
59        }

60    }

61    #endregion

62
63}

转载于:https://www.cnblogs.com/cm8448940/archive/2008/07/28/1254431.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值