I don't understand why using $old_password
in $new_password = crypt($password, $old_password)
generates the same echo results for $new_password
and $old_password
at the bottom of the following code.
I would be thinking that we need to use some kind of salt as the second paramater and not the $old_password
(already encrypted one).
$password = "secret"; // Usually from a form
$format = "$2y$10$";
$salt = "iusesomecrazystrings22";
$format_and_salt = $format . $salt;
// Initializing Values
$old_password = crypt($password, $format_and_salt);
$new_password = crypt($password, $old_password);
echo $new_password; //will echo $2y$10$iusesomecrazystrings2uVot5BCtPGBrRuQch85uTPr2L2fKlh0y
echo "<br>";
echo $old_password; //will echo the same as above $2y$10$iusesomecrazystrings2uVot5BCtPGBrRuQch85uTPr2L2fKlh0y
I was experimenting with the code and I went over the php.net manual and google.com results.