【问题标题】:Is there any way for Decrypt Password in aspnet_Membership table?有没有办法在 aspnet_Membership 表中解密密码?
【发布时间】:2013-12-07 07:30:04
【问题描述】:

我忘记了管理员密码。我必须为 Web 应用程序添加新用户。

我不知道 aspnet_Membership 表中的密码是用哪种方法加密的。

例如

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

密码:zEttVSSsEktBXeAHKiB+ihtD9OY=

密码盐: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# 程序解密

    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�

【问题讨论】:

    标签: c# sql encryption asp.net-membership decoding


    【解决方案1】:

    不存储密码,仅存储密码的哈希值。这确保了当有人掌握了你的数据库时,这个人无法弄清楚每个人的密码。您需要更改或重置您要访问的用户的密码。

    如果您想更改密码,有几种方法可用。例如你可以运行

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

    有关更完整的列表,请参阅this article

    【讨论】:

    • 如何重置我想要用户的密码?我只有一个管理员用户,我忘记了密码。
    猜你喜欢
    • 2021-01-10
    • 1970-01-01
    • 2020-07-16
    • 1970-01-01
    • 2021-12-26
    • 2013-08-20
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多