繁体   English   中英

在aspnet_Membership表中有解密码的方法吗?

[英]Is there any way for Decrypt Password in aspnet_Membership table?

我忘记了admin的密码。我必须为web应用程序添加新用户。

我不知道aspnet_Membership表中哪个方法加密密码。

例如

select * from aspnet_Membership where UserId='5c908238-f526-4f4c-aac6-a4b284483137'

密码:zEttVSSsEktBXeAHKiB + ihtD9OY =

PasswordSalt:v20qOhDVPnwzY8KPimy9XA ==

在web.config中

     <membership defaultProvider="eaMemberShipProvider" userIsOnlineTimeWindow="15">
<providers>

    <add name="eaMemberShipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web,
   Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

    connectionStringName="MyDB" 
   enablePasswordRetrieval="false" enablePasswordReset="true" 

   requiresQuestionAndAnswer="true" 
    applicationName="MyApplication" requiresUniqueEmail="false" passwordFormat="Hashed" 

    maxInvalidPasswordAttempts="5" 
     minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" 

      passwordAttemptWindow="10" passwordStrengthRegularExpression="" />

  </providers>
    </membership>

我尝试用C#中的程序解密Decrypt

    public static string EncodePasswordToBase64(string password)
    {
        try
        {
            byte[] encData_byte = new byte[password.Length];
            encData_byte = System.Text.Encoding.UTF8.GetBytes(password);
            string encodedData = Convert.ToBase64String(encData_byte);
            return encodedData;
        }
        catch (Exception ex)
        {
            throw new Exception("Error in base64Encode" + ex.Message);
        }
    }


    public string DecodeFrom64(string encodedData)
    {
        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();

        System.Text.Decoder utf8Decode = encoder.GetDecoder();

        byte[] todecode_byte = Convert.FromBase64String(encodedData);

        int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        string result = new String(decoded_char);
        return result;
    }


   private void button2_Click(object sender, EventArgs e)
    {
        textBox3.Text = DecodeFrom64(textBox2.Text);
    } 

对于此密码zEttVSSsEktBXeAHKiB + ihtD9OY =

Textbox3 = KmU$ KA] *〜 C

密码不存储,只是密码的哈希值。 这可以确保当有人掌握您的数据库时,此人无法找出每个人的密码。 您需要更改或重置要访问的用户的密码。

如果要更改密码,可以使用多种方法。 比如你可以跑

MembershipUser usr = Membership.GetUser(username);
string resetPwd = usr.ResetPassword();
usr.ChangePassword(resetPwd, newPassword);

有关更完整的列表,请参阅此文章

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM