或者就直接使用sql语句实现也行!!!

解决方案 »

  1.   

    //加密验证密码
    private string Run_MD5(string strText)
    {

    byte[] md5Bytes = System.Text.Encoding.Unicode.GetBytes(strText);
    MD5CryptoServiceProvider md5Encrypt = new MD5CryptoServiceProvider();
    byte[] EncryptString= md5Encrypt.ComputeHash(md5Bytes);
    strText = System.Text.Encoding.Unicode.GetString(EncryptString);
    return strText;
    }
      

  2.   

    当然,加上引用:
    using System.Web.Security;
    using System.Security.Cryptography;
      

  3.   

    private  string GetEncryptString(string inputString)
    {
    System.Security.Cryptography.MD5CryptoServiceProvider obj = new System.Security.Cryptography.MD5CryptoServiceProvider();
    byte[] bInput = System.Text.Encoding.Default.GetBytes(inputString);
    byte[] bRet=obj.ComputeHash(bInput);
    string res ="";
    for (int i=0;i<bRet.Length;i++)
    {
    res += bRet[i].ToString().PadLeft(2,'0');
    }
    return res; }
      

  4.   

    using System.Web.Security;string strHashPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5");orstring strHashPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1");
      

  5.   

    在注册加密密码后,用登录要怎么办呢????我的password字段是varchar(20)的字段类型!!
      

  6.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=1481D80A-F0FD-45E3-A822-94F5BE8C8813
      

  7.   

    password字段是varchar(20) ?  change to binary is better
      

  8.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=35935
      

  9.   

    用哈稀函数加密啊 
    数据结构里面最经典的
    using System.Web.Security;string strHashPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5"或者"sha1");把strHashPassword存到数据库即可 也就是你的char型.......
      

  10.   

    lkk2073(三楼楼长),你这种加密方法可以逆操作吗?如何还原,因为有些情况下可能还是需要查看原文到底是什么的
      

  11.   

    以前用VB写的算法,你可以“翻译”成C#啦'加密口令串
    Public Function EncryptPassword(ByVal normal As String) As String
        Dim varEncrypt As String
        Dim newString As String
        Dim temp As Double
        Dim temp2 As Double
        Dim temp3 As Double
        Dim temp4 As Double
        Dim i, j As Integer
        Dim xarray(25) As Integer
        Dim Count As Integer
        On Error GoTo errHandle
        xarray(0) = 12
        xarray(1) = 9
        xarray(2) = 13
        xarray(3) = 19
        xarray(4) = 10
        xarray(5) = 3
        xarray(6) = 6
        xarray(7) = 2
        xarray(8) = 11
        xarray(9) = 15
        xarray(10) = 1
        xarray(11) = 24
        xarray(12) = 16
        xarray(13) = 8
        xarray(14) = 4
        xarray(15) = 5
        xarray(16) = 25
        xarray(17) = 7
        xarray(18) = 14
        xarray(19) = 21
        xarray(20) = 6
        xarray(21) = 20
        xarray(22) = 22
        xarray(23) = 18
        xarray(24) = 23
        xarray(25) = 17
        newString = ""
        Count = 0
        For i = 1 To Len(normal)
            
            If Count = 25 Then Count = 0
            
            temp = Asc(Mid(normal, i, 1))
            temp2 = xarray(Count)
                
            temp3 = temp Xor temp2
            'Calculations
            temp3 = Abs(temp3)
            If temp3 = 39 Then temp3 = 128
            
            newString = newString & Chr(temp3)
            
            Count = Count + 1
        Next i
        EncryptPassword = newString
        Exit Function
    errHandle:
        MM1_FormatError (MM1_SetError(Err.Number, Err.Description, App.EXEName, "EncryptPassWord"))
    End Function'解密口令串
    Public Function DecryptPassword(ByVal normal As String) As String
        Dim varEncrypt As String
        Dim newString As String
        Dim temp As Double
        Dim temp2 As Double
        Dim temp3 As Double
        Dim temp4 As Double
        Dim i, j As Integer
        Dim xarray(25) As Integer
        Dim Count As Integer
        
        On Error GoTo errHandle
        
        xarray(0) = 12
        xarray(1) = 9
        xarray(2) = 13
        xarray(3) = 19
        xarray(4) = 10
        xarray(5) = 3
        xarray(6) = 6
        xarray(7) = 2
        xarray(8) = 11
        xarray(9) = 15
        xarray(10) = 1
        xarray(11) = 24
        xarray(12) = 16
        xarray(13) = 8
        xarray(14) = 4
        xarray(15) = 5
        xarray(16) = 25
        xarray(17) = 7
        xarray(18) = 14
        xarray(19) = 21
        xarray(20) = 6
        xarray(21) = 20
        xarray(22) = 22
        xarray(23) = 18
        xarray(24) = 23
        xarray(25) = 17
        newString = ""
        Count = 0
        For i = 1 To Len(normal)
            If Count = 25 Then Count = 0
            temp = Asc(Mid(normal, i, 1))
            If temp = 128 Then temp = 39
            temp2 = xarray(Count)
            temp3 = temp Xor temp2
            'Calculations
            temp3 = Abs(temp3)
            newString = newString & Chr(temp3)
            Count = Count + 1
        Next i
            DecryptPassword = newString
        Exit Function
    errHandle:
        MM1_FormatError (MM1_SetError(Err.Number, Err.Description, App.EXEName, "DecryptPassword"))
    End Function
      

  12.   

    this.Label1.Text=FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox1.Text,"SHA1"); 
    this.Label2.Text=FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox1.Text,"MD5");