I have this code
<?php
error_reporting(E_ALL);
$caratteri_disponibili ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
$lunghezza= 50;
$code = "";
for($i = 0; $i<$lunghezza; $i++){
$code = $code.substr($caratteri_disponibili,rand(0,strlen($caratteri_disponibili)-1),1);
}
$hashed_password = crypt('mypassword',$code);
?>
To crypt a password with a random salt. Error_reporting does not notify me about any mistakes, but when I try to check if the hashed password matches with an other input using this code (put in the same page of the previous one)
<?php
$input = "Hey";
if (crypt($input, $hashed_password) == $hashed_password) {
echo "Password verified!";
}
?>
I'm told 'Password verified!' even if I should not. What am I doing wrong?