$maxAgeSeconds || !preg_match('/^sha256=[a-f0-9]{64}$/iD', $signature)) { return false; } $expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret); return hash_equals($expected, strtolower(substr($signature, 7))); }