Files
oficial/app/src/Service/HMAC.php

16 lines
540 B
PHP
Raw Normal View History

<?php
namespace Incoviba\Service;
use Incoviba\Common\Ideal;
class HMAC extends Ideal\Service
{
2025-06-03 23:04:57 -04:00
public function validate(string $timestamp, string $requestSignature, string $requestId, string $secret): bool
{
$message = "{$timestamp}.{$requestId}";
$encodedSecret = mb_convert_encoding($secret, 'UTF-8');
$encodedMessage = mb_convert_encoding($message, 'UTF-8');
$hmacObject = hash_hmac('sha256', $encodedMessage, $encodedSecret);
2025-06-03 23:07:47 -04:00
return hash_equals($hmacObject, $requestSignature);
}
}