- substr: documentation ( source)
- var_dump: documentation ( source)
- crypt: documentation ( source)
- error_reporting: documentation ( source)
- rand: documentation ( source)
<?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);
$input = "Hey";
if (crypt($input, $hashed_password) == $hashed_password) {
echo "Password verified!";
}
var_dump($hashed_password, crypt($input, $hashed_password));