Couldn't find any complete examples on how to do this, so here is one:
define('AUTHORIZE_SIGNATURE_KEY', 'abc123');
$body = file_get_contents('php://input');
$headers = getallheaders();
$header = $headers['X-ANET-Signature'];
parse_str($header, $output);
// need to match case since PHP will generate the hash as lowercase
$signature = strtolower($output['sha512']);
$hash = hash_hmac('sha512', $body, AUTHORIZE_SIGNATURE_KEY);
if($hash === $signature) {
echo "signature matches";
}
Top comments (0)