using System.Security.Cryptography;

namespace SirayaPrinter.Sync;

public static class HashUtil
{
    public static string Sha256File(string filePath)
    {
        using var stream = File.OpenRead(filePath);
        var hash = SHA256.HashData(stream);
        return Convert.ToHexString(hash).ToLowerInvariant();
    }

    public static bool Matches(string filePath, string expectedSha256)
    {
        if (!File.Exists(filePath)) return false;
        var actual = Sha256File(filePath);
        return actual.Equals(expectedSha256, StringComparison.OrdinalIgnoreCase);
    }
}
