I would like to hear if this is safe enough for storing passwords in a mysql DB.
<?php
$password=hash('sha512',$_POST['password']);
//and then insert it into and mysql database
?>
Is this safe? If not how could I do it more safe?
I would like to hear if this is safe enough for storing passwords in a mysql DB.
<?php
$password=hash('sha512',$_POST['password']);
//and then insert it into and mysql database
?>
Is this safe? If not how could I do it more safe?
Basic, straight hashes have not been considered safe for years. md5
has been outright broken for years. Salted hashes have been considered best practice up until maybe 6-8 years ago, but now they are no longer considered safe either.
Please use one of the following methods to encrypt your passwords securely:
The key to all of these functions is that they are designed to run slowly. In particular, where traditional hashing algorithms can be run millions or billions of times a second, allowing an attacker to brute force your passwords in a reasonable amount of time, these functions can be tuned to only run 10 times a second, or twice, or once, or even take several seconds to complete. You would never want to set these algorithms to run in that way, you'd probably want to tune it so it would complete in 1/10 to 3/10 of a second, which would be almost imperceptible to your users, but would still make brute forcing impractical.
I would suggest using blowfish http://www.php.net/manual/en/function.crypt.php Use a custom generated salt