Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hashing vs. Encrypting Passwords

I'm using ASP.NET membership for a site that will serve primarily sophisticated users. I understand the difference between hashed and encrypted passwords, and I'm trying to decide between the two.

After my last client complained bitterly about hashed passwords being a total PITA, I've started to favor encrypted passwords. But someone suggested this just isn't secure enough.

So my question is: What, exactly are the risks of encrypting passwords? Any person with the ability to steal passwords by decrypting them from the database would surely have the ability to reset them if they were hashed, no? I'm having trouble seeing where someone could cause trouble with encrypted passwords but couldn't with hashed ones. Making it convenient for users is also important.

like image 952
Jonathan Wood Avatar asked Nov 29 '22 18:11

Jonathan Wood


2 Answers

The risk with decryptable passwords is that people use the one password for various logins and accounts, not just for the application you are dealing with.

  • With an encrypted password, a stolen/decrypted password could be tried out on users' other accounts (e.g. a stolen banking password could lead to access to their email).
  • With a hashed password, there is no recovery. Theft of password hashes should never easily yield usable passwords

Treat passwords as the property of the account owner. It's not yours to view, decrypt, or do other things with. If a user forgets their password, offer reset, and not retrieval.

like image 125
Stoive Avatar answered Dec 06 '22 16:12

Stoive


The point is that Encrypted passwords can be decrypted...so it is possible that with having access to the keys etc all the passwords could be known.

Hashed (with salt) passwords are a 1 one function so there is effectively no possible way of determining what the password was which means the user supplying the password has less to worry about. Sure someone could change the hash in where ever it is stored (e.g. database) so that user could no longer log on, but the password they had provided originally still wouldn't be known.

Edit
As you've tagged the question ASP.Net, I'd recommend using BCrypt.Net library to generate your hashes

like image 21
davidsleeps Avatar answered Dec 06 '22 16:12

davidsleeps