Decryption problem

1

I have a session in MySQL with PHP of a somewhat advanced encryption in PHP using Sha512 , I'm having trouble reverting it to decrypt the data.

 
function gen_token($pass, $salt)
{
   $salt = strtolower($salt);
   $str = hash("sha512", $pass.$salt);
   $len = strlen($salt);
   print strtoupper(substr($str, $len, 17));
}

Example:

gen_token("123456789", "thalys");

Password Exit:

8B9C96128F1517479 
    
asked by anonymous 22.06.2014 / 02:35

1 answer

1

The idea of a hash is that it is irreversible even ... So even those who have access to the database can not know what the user's passwords are, just the hash of the passwords.

You should run this function again on the password you entered during the login attempt and compare it with the original password saved in the database.

Something like:

if (gen_token($_POST['senha'], "thalys") == "8B9C96128F1517479")
    echo "senha correta!";
    
22.06.2014 / 03:06