Q:

how to encrypt and decrypt characters using hashing in PHP

Hi am using hashing for my project. I was created encryption correctly that code is following:
<?php 
function cryptPass($input, $rounds = 9) {
    $salt = "";
    $saltChars = array_merge(range('A','Z'), range('a','z'), range('0','1'));
    for($i = 0; $i < 22; $i++)
    {
        $salt .=$saltChars[array_rand($saltChars)];
    }
    return crypt($input, sprintf('$2y$%02d$', $rounds). $salt);
}
$pass = "passsword";
$hasedpass = cryptPass($pass);
echo $hasedpass;
echo '<br>';
?>

My result is: $2y$09$HICRjrIyBYXWqcqRFC1dDOXF9tTtKZeOTBewebsooxHtWvvepqrnu
Now my question is how to decrypt $hasedpass.
I mean the result will be come password $pass values.

A:

From the documentation:

crypt — One-way string hashing

You can't decrypt a one-way hash. That is the point of using a one-way hash.
If you want to find out if a password is correct then take the submitted password, crypt it with the same salt, then compare the result to the stored, hashed version.

