Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a form in which how can compare user id and password which is stored in database.
Please provide me solution.
Posted

It seems quite improbable that you need help comparing the data. Since all you need to do is use the == operator.

Example:

C#
if(passwordEntered == GetPasswordFromDB(usernameEntered))
{
   // you are now authenticated
   
}


Note: See OriginalGriff's answer where he describes how you can avoid storing and comparing the password in clear text.
 
Share this answer
 
v5
Use a SHA hash of the password and compare that with the database stored value. That way, the password is not held in clear at any time and cannot be stolen. It is also a good idea to include the username/userid in the password string before generating the SHA code to prevent two users with teh same password having identical SHA codes.
The userid can be stored in clear.
 
Share this answer
 
Comments
Nish Nishant 31-Oct-10 9:09am    
Voted 5, marked as answer.
Dalek Dave 31-Oct-10 10:12am    
Gooad Response.

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