Skip to content

Instantly share code, notes, and snippets.

@danpalmieri
Last active September 27, 2023 09:22
Show Gist options
  • Save danpalmieri/168432849fd95449b5324ef4891bc9aa to your computer and use it in GitHub Desktop.
Save danpalmieri/168432849fd95449b5324ef4891bc9aa to your computer and use it in GitHub Desktop.
PHP: Verificar se a Signature do Webhook da Svelve é válida
<?php
/**
* Verify the signature of a signed request.
*
* @param string $signature The signature parameter from the request.
* @param string $payload The payload to verify.
* @param string $token The signing token.
* @return boolean
*/
public static function verifySignature(string $signature, string $payload, string $token): bool
{
$computedSignature = hash_hmac('sha256', $payload, $secret);
return hash_equals($signature, $computedSignature);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment