0
0
mirror of https://github.com/sp-tarkov/installer.git synced 2025-02-13 06:50:45 -05:00
installer/Aki.Helper/FileHashHelper.cs

25 lines
689 B
C#

using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
namespace SPT_AKI_Installer.Aki.Helper
{
public static class FileHashHelper
{
public static bool CheckHash(FileInfo file, string expectedHash)
{
using (MD5 md5Service = MD5.Create())
using (var sourceStream = file.OpenRead())
{
byte[] sourceHash = md5Service.ComputeHash(sourceStream);
byte[] expectedHashBytes = Convert.FromBase64String(expectedHash);
bool matched = Enumerable.SequenceEqual(sourceHash, expectedHashBytes);
return matched;
}
}
}
}