Secure hash and salt for PHP passwords
- by luiscubal
It is currently said that MD5 is partially unsafe.
Taking this into consideration, I'd like to know which mechanism to use for password protection.
Is “double hashing” a password less secure than just hashing it once?
Suggests that hashing multiple times may be a good idea.
How to implement password protection for individual files?
Suggests using salt.
I'm using PHP. I want a safe and fast password encryption system. Hashing a password a million times may be safer, but also slower. How to achieve a good balance between speed and safety? Also, I'd prefer the result to have a constant number of characters.
The hashing mechanism must be available in PHP
It must be safe
It can use salt (in this case, are all salts equally good? Is there any way to generate good salts?)
Also, should I store two fields in the database(one using MD5 and another one using SHA, for example)? Would it make it safer or unsafer?
In case I wasn't clear enough, I want to know which hashing function(s) to use and how to pick a good salt in order to have a safe and fast password protection mechanism.
EDIT: The website shouldn't contain anything too sensitive, but still I want it to be secure.
EDIT2: Thank you all for your replies, I'm using hash("sha256",$salt.":".$password.":".$id)
Questions that didn't help:
What's the difference between SHA and MD5 in PHP
Simple Password Encryption
Secure methods of storing keys, passwords for asp.net
How would you implement salted passwords in Tomcat 5.5