【发布时间】: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