Let's say I have thousands of users and I want to make the passwords very secure. Now, I've learned that md5()
is not the safest to use, however what I think can be done to be safe is salt it (I know this is nothing new). So for this I was thinking of creating two tables, one called accounts
which will have all information associated with accounts and a table column called salt
and the second table would be called something like auth
and have the fields account_id, password
to start, I create a salt upon registration (generated randomly)
$salt = "#52/sBsO8";
then all the provided information goes to accounts
salt being one of them
then after successfully putting the information in database, I create the password that is going to be stored in auth
table, this way the password is not the md5 of the password the user enters, rather its the md5 of the salt and the password user enters
so the password in auth
is
$password = md5($user_entered_password . $salt);
Test strings: PHP Code
$password = "123";
$salt = "#52/sBsO8";
echo md5($password) ." / ";
echo md5($password . $salt);
output: 202cb962ac59075b964b07152d234b70 / dfbf0b257c5182af0ae893c2680f4594
The question is: Is this a pretty safe way of dealing with passwords? Because of md5()
decrypting websites, there are so many ways to guess the passwords. And the decrypting websites don't actually decrypt the md5()
they just have the md5 hashes of millions of strings.