public function verifyHMAC($data) { $data = base64_decode($data); if (Utils::binaryStrlen($data) <= 32) { return false; } $hash = Utils::binarySubstr($data, -32, 32); $data = Utils::binarySubstr($data, 0, -32); $newhash = hash_hmac('sha256', $data, $this->getHMACSecret(), true); return Utils::compareStr($hash, $newhash) ? $data : false; }
/** * Verify the input against an existing Hash * * The function will determine the Hash algorithm and parameters from the * $existingHash. * * @param sting $input * @param string $existingHash * * @return True if the input matches the existing Hash */ public function verify($input, $existingHash) { $hash = crypt($input, $existingHash); return Utils::compareStr($existingHash, $hash); }