Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:49:14+00:00 2026-06-14T06:49:14+00:00

I can’t seem to find out how I should decrypt the encrypted password using

  • 0

I can’t seem to find out how I should decrypt the encrypted password using sha1 via the membership provider.

I can’t use the .GetPassword() method here because I’m retrieving the values from a sqldatasource and placing them into a gridview.

Here’s the 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>

I have replaced the boundfield with an itemtemplate in a Templatefield.
The label inside the itemtemplate is bound to the username, the label has also an OnDataBind=”Decrypt” that should decrypt the value in the Text attribute of the label.
I’ve been trying a few examples I found online (even from this forum), but my understanding of .net is not that fantastic yet.
Here’s what I tried in the decrypt() listener:

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;
}

I was trying to get the username decrypted first, I suppose it’s the same method for the password.
To eleminate further questions, here’s my setup in 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"/>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:49:15+00:00Added an answer on June 14, 2026 at 6:49 am

    SHA1 is a hashing algorithm, not an encryption algorithm, and hashes are by definition one way, so they cannot be undone. as such you would never use sha to “decrypt” anything, let alone a hash.

    your data appears to be encrypted by AES, not sha. also you are confusing encoding with encryption.
    Here is some infomation about using AES in .net: http://msdn.microsoft.com/en-us/library/system.security.cryptography.aes.aspx

    encoding is all about interpreting byte data as characters in one scheme or another (ascii, unicode, UCT-8) so once you have the data decrypted, you may have to encode it into a string for display, but that is secondary to the decryption.

    ADDENDUM: you may not be able to avoid using membership.GetPassword() since the encryption key in use in your membership DB implementation may not be retrievable. have you considered using an object datasource instead? then you could prefill a list of entries in code using .GetPassword() and bind them to the grid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I authenticate with just Google account username and password instead of using OAuth?
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone help me trying to find out why this doesn't work. The brushes
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can PHP PDO extension bind nested objects automatically ? I mean using foreign key
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can't figure out how to do this in a pretty way : I have
Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
Can any one help me in sorting this out in sed/awk/perl Input file Start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.