我忘记了admin的密码。我必须为网络应用添加新用户。
我不知道在aspnet_Membership表中为密码加密了哪种方法。
E.g
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#中的程序来解密这个
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
答案 0 :(得分:4)
密码未存储,只是密码的哈希值。这可以确保当有人掌握您的数据库时,此人无法找出每个人的密码。您需要更改或重置您要访问的用户的密码。
如果要更改密码,可以使用多种方法。例如,您可以运行
MembershipUser usr = Membership.GetUser(username);
string resetPwd = usr.ResetPassword();
usr.ChangePassword(resetPwd, newPassword);
有关更完整的列表,请参阅this article。