What is the safest way that I could could hash/encrypt a password for my website?
2 Answers
"Safest" depends on the circumstances and context; there is no one-size-fits-all absolute answer.
However, there is a lot of accumulated knowledge on the subject. Basically, you want a one-way hashing process, so that someone who gets some read access to your server does not immediately obtains a usable copy of the passwords. The hashing process should also deter parallel attacks (that's what salt are used for) and be configurably slow (as slow as you can tolerate on your machine, as an attempt to slow down the attacker too).
Read this first; it should answer most of your questions and provide links.
There isn't really a safest way, but these things are the best tips I can offer:
- Use a one-directional hash, not an encryption, and compare hashed user input to stored hashes.
- Add a salt. Instead of hashing 'password', which could easily be looked up in a dictionary of hashes, hash something like 'SALTpassword', where SALT is a string of characters you decide upon, and keep secret.
- Constantly review the system you end up using, keep an eye out for suddenly found vulnerabilities
- Enforce a policy of using decent passwords.
^ That should get you off to a good start, some reading up on password theory and opinion would also be a good idea.

- 1,086
- 5
- 9
Given the entry level of the question, I didn't think a deeper delve into password theory was a good move, but fair point that there is much more password hashing than just salting.
– Owen Oct 16 '13 at 17:03