locked
get password RRS feed

  • Question

  • User-24013712 posted

    Hi all.

    I want to get password from Membership table sql server. But it is not showing correct password. My password is 123 but it is still showing encrypted. Please help me. Here is my code.

        protected void Page_Load(object sender, EventArgs e)
        {
           DataSet Ds1;
            conquery fq1 = new conquery();
            string strsql;
            strsql = "select * from aspnet_Membership where UserId='E40A360'";
            Ds1 = fq1.bindDataSet(strsql);
            if (Ds1.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dsrow in Ds1.Tables[0].Rows)
                {
                    txtPassword.Text = Convert.ToString(dsrow["Password"]);
                    str1 = DecodeFrom64(txtPassword.Text);
                }
            }
        }

        public string DecodeFrom64(string password)
        {
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(password);
            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);
            result = new String(decoded_char);
            return result;
        }

    Tuesday, July 26, 2016 10:03 AM

Answers

  • User283571144 posted

    Hi noorhaan,

    I want to get password from Membership table sql server. But it is not showing correct password. My password is 123 but it is still showing encrypted. Please help me. Here is my code.

    As far as I know, if you use Microsoft provider SqlMembershipProvider, you will find a table "aspnet_Membership" which store the passoword.

    In this table you will find a column named 'PasswordFormat'.

    PasswordFormat int Password format (0=Plaintext, 1=Hashed, 2=Encrypted)

    I suggest you could firstly make sure which PasswordFormat is used in your password.

    More details about Membership Providers you could refer to follow link:

    https://msdn.microsoft.com/en-us/library/aa478949.aspx

    Besides, you could refer to follow article :

    Decrypt user password in ASP.Net SqlMembershipProvider

    http://www.byteblocks.com/post/2011/05/03/Decrypt-password-in-SqlMembershipProvider.aspx

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 28, 2016 8:41 AM

All replies