2

How to get the actual password from aspnet_Users (it's encrypted)

without the use of Membership I need normal select statement and convert the password to the real one I tried the following code as example

static void Main(string[] args)
        {
            using (PMAEntities context = new PMAEntities())
            {

                var Query = from U in context.aspnet_Users
                            join M in context.aspnet_Membership on U.UserId equals M.UserId
                            where U.UserName == "admin"
                            select new
                            {
                                password = (string)M.Password,
                                salt = (string)M.PasswordSalt

                            };
                if (Query != null)
                {
                    // Convert the input password to bit array
                    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                     byte[] inputpassword=  encoding.GetBytes("123456");
                     byte[] salt = encoding.GetBytes(Query.FirstOrDefault().salt);
                    byte[]commingpass = encoding.GetBytes(Query.FirstOrDefault().password);
                    // Combine the two arrays 
                    byte[] c = new byte[inputpassword.Length + salt.Length];
                     System.Buffer.BlockCopy(inputpassword, 0, c, 0, inputpassword.Length);
                     System.Buffer.BlockCopy(salt, 0, c, inputpassword.Length, salt.Length); 

                    //Comparer 

                    if(c.SequenceEqual(commingpass))
                    {
                        Console.WriteLine("Hiiiiiiiiiii");

                    }
                    Console.ReadLine();


                }






            }
        }

Best regards

AMH
  • 6,363
  • 27
  • 84
  • 135

1 Answers1

0

Don't decrypt the password, as Aristos said, it's a bad idea because you are compromising the security of your users. If all you want to do is allow the users to login, here is an alternative solution: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=344

stralsi
  • 988
  • 1
  • 10
  • 17