Decryption problem

Asked

Viewed 70 times

1

I have a Mysql session with PHP of a somewhat advanced PHP encryption using Sha512, I’m having trouble reversing 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 output:

8B9C96128F1517479 

1 answer

1

The idea of a hash is that it is irreversible even... So even those who have access to the database cannot know what the users' passwords are, only the password hash.

You should run this function again in the password entered during the login attempt and compare with the output of the original password recorded in the bank.

Something like:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.