Skip to content

Instantly share code, notes, and snippets.

@turret-io
turret-io / verify_hmac.php
Last active May 5, 2025 07:34
Verify HMAC in PHP
<?php
define("SHARED_SECRET", "sup3rs3cr3t!!");
if(!function_exists('hash_equals')) {
function hash_equals($str1, $str2) {
// Run constant-time comparison for PHP < 5.6 which doesn't support hmac_equals
$str1_len = strlen($str1);
$str2_len = strlen($str2);