<?php

namespace App\Services;

class TrackingHelper
{
    public static function token(int $campaignId, int $contactId): string
    {
        return substr(hash_hmac('sha256', "{$campaignId}:{$contactId}", config('app.key')), 0, 32);
    }

    public static function verify(int $campaignId, int $contactId, string $token): bool
    {
        return hash_equals(static::token($campaignId, $contactId), $token);
    }
}
