Last active
September 27, 2023 09:22
-
-
Save danpalmieri/168432849fd95449b5324ef4891bc9aa to your computer and use it in GitHub Desktop.
PHP: Verificar se a Signature do Webhook da Svelve é válida
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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