2023-02-17 378
我似乎无法通过会员提供者使用SHA1来确定如何使用SHA1解密加密密码.
我在这里无法使用.getPassword()方法,因为我正在从sqldatasource检索值并将它们放入gridview中.
这是GridView:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserId" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
<Columns>
<asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
<asp:TemplateField HeaderText="Block users">
<ItemTemplate>
<asp:Button runat="server" ID="btnBlock" CommandName="Block" CommandArgument='<%# Eval("UserId") %>'
Text="Block" OnClick="btnBlock_Click" Visible='<%# !Convert.ToBoolean(Eval("IsLockedOut")) %>' />
<asp:Button runat="server" ID="btnDeblock" CommandName="Deblock" CommandArgument='<%# Eval("UserId") %>'
Text="Deblock" OnClick="btnBlock_Click" Visible='<%# Convert.ToBoolean(Eval("IsLockedOut")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Username">
<ItemTemplate>
<asp:Label ID="UserId" runat="server" Text='<%# Bind("UserId") %>' OnDataBinding="Decrypt" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserId" HeaderText="User id" ReadOnly="True"
SortExpression="UserId" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="LastLoginDate" HeaderText="Last login"
SortExpression="LastLoginDate" />
<asp:CheckBoxField DataField="IsLockedOut" HeaderText="Locked"
SortExpression="IsLockedOut" />
<asp:BoundField DataField="FailedPasswordAttemptCount"
HeaderText="Failed logins"
SortExpression="FailedPasswordAttemptCount" />
<asp:BoundField DataField="Comment" HeaderText="Comments"
SortExpression="Comment" />
</Columns>
</asp:GridView>
我已经用模板字段中的ItemTemplate代替了边界.
ItemTemplate内部的标签绑定到用户名,标签还具有一个ondatabind =”解密”,该标签应该解密标签的文本属性中的值.
我一直在尝试在网上找到一些示例(即使是在这个论坛上),但是我对.NET的理解还不是很棒.
这是我在Decrypt()听众中尝试的内容:
public void Decrypt(object sender, EventArgs e)
{
Label lbl = (Label)sender;
string decrypted = string.Empty;
UTF8Encoding encode = new UTF8Encoding();
Decoder Decode = encode.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(lbl.Text);
int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
decrypted = new String(decoded_char);
lbl.Text = decrypted;
}
我试图首先将用户名解密,我想这是密码的相同方法.
为了提出更多的问题,这是我在web.config
中的设置
<membership defaultProvider="MembershipProvider">
<providers>
<clear/>
<add name="MembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="GustaafConnectionString"
applicationName="Gustaaf" enablePasswordRetrieval="true" enablePasswordReset="false" requiresQuestionAndAnswer="true"
requiresUniqueEmail="false" passwordFormat="Encrypted"/>
</providers>
</membership>
<machineKey validationKey="..." decryptionKey="..." validation="SHA1" decryption="AES"/>
sha1是一种哈希算法,而不是加密算法,并且在定义上是一种方法,因此不能撤消它们.因此,您永远不会使用SHA”解密”任何东西,更不用说哈希了.
您的数据似乎是由AES而不是SHA加密的.另外,您将编码与加密混淆.
这是关于在.NET中使用AES的一些信息: http:http:http:http:http:http:http:http:http:http:http:http://msdn.microsoft.com/en-us/library/system.security.cryptography.aes.aspx
编码都是关于将字节数据解释为一个或另一个方案中的字符(ascii,unicode,uct-8),因此一旦将数据解密后,您可能必须将其编码为字符串以进行显示,但这是次要的解密.
附录:您可能无法避免使用MENSTER.GEGPASSWORD(),因为在您的会员数据库实现中使用的加密密钥可能无法检索.您是否考虑过使用对象数据源?然后,您可以使用.getPassword()将代码中的条目列表预填写并将其绑定到网格.
以上所述是小编给大家介绍的asp.net加密的会员密码和用户名检索,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/34130.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态