0

Magento version 1.9.3.6

Full Error:

Fatal error: Call to undefined function hash_equals() in /var/www/vhosts/lassco/htdocs/app/code/core/Mage/Core/Model/Encryption.php on line 103

This occurs when I enter my admin details to login to the magento cms

I've checked my functions.php file and it seems to be patched correctly with the following code at the end of the file.

if (!function_exists('hash_equals')) {
    /**
     * Compares two strings using the same time whether they're equal or not.
     * A difference in length will leak
     *
     * @param string $known_string
     * @param string $user_string
     * @return boolean Returns true when the two strings are equal, false otherwise.
     */
    function hash_equals($known_string, $user_string)
    {
        $result = 0;

        if (!is_string($known_string)) {
            trigger_error("hash_equals(): Expected known_string to be a string", E_USER_WARNING);
            return false;
        }

        if (!is_string($user_string)) {
            trigger_error("hash_equals(): Expected user_string to be a string", E_USER_WARNING);
            return false;
        }

        if (strlen($known_string) != strlen($user_string)) {
            return false;
        }

        for ($i = 0; $i < strlen($known_string); $i++) {
            $result |= (ord($known_string[$i]) ^ ord($user_string[$i]));
        }

        return 0 === $result;
    }
}

Any help would be appreciated, thank you

2 Answers 2

1

hash_equals are not available on PHP versions prior to 5.6

1
  • The patch in the functions.php file covers that issue
    – GApple
    Commented Nov 21, 2017 at 11:29
0

This library has a bug.

Mage.php line 51 uses

include_once "Mage/Core/functions.php";

When it should be

include_once "app/code/core/Mage/Core/functions.php";

This is only the case for when trying to login on the admin page though

A fix would be great

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.