Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a Web Login Form For User Signup and Login. First i found that to securely store password in database, i should use hash and salt on .net pages. Then i came to know that there is a function in sql server Hash-bytes that also hashes the password, where i can store the plain password coming form text box in aspx page and in sql insert this plian text passowrd in hashbytes and then store it. on validation i just compare the stored hash passowrd with the user entered password.

Now i want to know that which technique is better and why?

unnecessary code tags removed
Posted
Updated 24-Apr-14 22:59pm
v2

If you are sending plain password to the database, the data originate in UI tier, ASP.NET. Therefore, before reaching the database, it passed through the network. This post can relatively easily be eavesdropped. No one is supposed to know your original password, even the database administrator with full privileges. If someone posts the hash of the password, the original password is never exposed to anything except your local computer, not even the database. The passwords stored in the database came in their hashed forms in first place; and the cryptographic hash function cannot be reversed (don't use MD5 or SHA-1 though, use, for example, one of SHA-2 algorithms). The hash is compared with hash.

For some background, please see: http://en.wikipedia.org/wiki/Cryptographic_hash_function[^].

One problem remains: someone could eavesdrop you hash and later impersonate you, but this is covered by using HTTPS protocol instead of HTTP: http://en.wikipedia.org/wiki/HTTPS[^].

See also my past answers:
i already encrypt my password but when i log in it gives me an error. how can decrypte it[^],
Decryption of Encrypted Password[^],
storing password value int sql server with secure way[^].

—SA
 
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