Click here to Skip to main content
15,917,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an ASP.NET website that I require a Windows Forms application to login and authenticate with the SQL database. The database is what was created when I first used the template in VS 2010. The page doesn't have any graphics and is just used by the application for authentication. After authentication, the site will respond with data that is sent to the app.

I do not understand how I can create the password hash (I presume it's a hash) in the application so it can be sent to the ASP.NET site.

I have looked all over the place to find the answer. I have tried the SHA1 .NET methods and nothing seems to give me what I am looking for.

Do I create the hashed password in the app and send it to the page? I can't see in the template how the password in being encrypted/hashed and compared to the hashed password in the database.

I guess if I could figure out how take the passed password from the app, use the PasswordSalt in the database with the correct hash and be able to come up with the password that resides in the database (for comparison)...I would be home and hosed. Right now I'm just hosed.

This is what I have in mind:
pwd = Request.QueryString["password"];
salt = retrieve salt from db.

SHA1 sha = new SHA1CryptoServiceProvider();

string saltAndPwd = String.Concat(pwd, salt);
hashedPwd = Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(saltAndPwd)));


The hash doesn't seem correct.

Any help would be appreciated.

Thanks.
Posted
Updated 21-Sep-10 4:56am
v3

1 solution

I just found out that I should be using the Membership class to access the db and verify the password for the user. This is in the namespace System.Web.Security. This helper class gives access to the tables and stored procedures in the database.

if (Membership.ValidateUser(Username, Password))
{
...
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900