Update: 2026-05-03 20:56:55

This commit is contained in:
Hamza-Ayed
2026-05-03 20:56:55 +03:00
parent 8af74f0621
commit b33513ebcf
3 changed files with 28 additions and 18 deletions

View File

@@ -28,4 +28,15 @@ final class Security
{
return bin2hex(random_bytes($length / 2));
}
public static function sign(string $data, string $secret): string
{
return hash_hmac('sha256', $data, $secret);
}
public static function verifySignature(string $data, string $signature, string $secret): bool
{
$expected = self::sign($data, $secret);
return hash_equals($expected, $signature);
}
}