Piwik\Plugins\Login\PasswordResetter::generateSecureHash PHP Method

generateSecureHash() protected method

We can't get the identifier back from a hash but we can tell if a hash is the hash for a specific identifier by computing a hash for the identifier and comparing with the first hash.
protected generateSecureHash ( string $hashIdentifier, string $data ) : string
$hashIdentifier string A unique string that identifies the hash in some way, can, for example, be user information or can contain an expiration date, or whatever.
$data string Any data that needs to be hashed securely, ie, a password.
return string The hash string.
    protected function generateSecureHash($hashIdentifier, $data)
    {
        // mitigate rainbow table attack
        $halfDataLen = strlen($data) / 2;
        $stringToHash = $hashIdentifier . substr($data, 0, $halfDataLen) . $this->getSalt() . substr($data, $halfDataLen);
        return $this->hashData($stringToHash);
    }