I have two curiosities about encryption of passes, I have this code:
1- $ mainpass="test123";
$md5pass = md5($mainpass);
$sha1pass = sha1($md5pass);
$cryptpass = crypt($sha1pass, 'st');
echo ($cryptpass);
Whose output is: 'stSuGIR46GScI'.
But I do not understand why this (below) is not equal and the output is always changing:
$mainpass = "test123";
$cryptpass = crypt(sha1(md5($mainpass)));
echo ($cryptpass);
By my logic would be equivalent.
2- And in checking and validating the password how would it change the code below that only has md5 to match the encryption made above (in the correct case)?
if(isset($_POST['username'], $_POST['password'])) {
$username = $_POST['username'];
$password = md5($_POST['password']);