If I hash for example a password twice:
$psw1= password_hash($password,PASSWORD_DEFAULT);
$psw2=password_hash($psw1,PASSWORD_DEFAULT);
Is this more secure or it this just useless?
P.S.: I am new to php
If I hash for example a password twice:
$psw1= password_hash($password,PASSWORD_DEFAULT);
$psw2=password_hash($psw1,PASSWORD_DEFAULT);
Is this more secure or it this just useless?
P.S.: I am new to php
This will prevent you from verifying the password, since you won't be able to reproduce the first hash, since you've discarded the random salt of the first hash. Instead, to increase security of a single hash, simply adjust its cost factor:
password_hash($password, PASSWORD_DEFAULT, ['cost' => 12])
The higher the cost, the more rounds of hashing will be done. Pick a cost that doesn't slow the process down too much, but isn't too low either. In fact, you should keep increasing the cost factor over time as better server hardware becomes available, and rehash your users passwords over time with the stronger algorithm. That's specifically what password_needs_rehash
is for.
I think is useless since once hashed it's impossible to know what the real value was...at least teorically speaking.
I suggest using strong hash functions like sha512 or ripemd320 since there are not much publicy available databases where hashed passwords are stored.
If you want to know more I've found an old question on stackoverflow with good answers : PHP dehashing the password