mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-07 07:46:22 +02:00
Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace HyperbolicDowloader.FileProcessing;
|
||||
|
||||
internal class FileValidator
|
||||
{
|
||||
public static async Task<string> CalculateHashAsync(string filePath)
|
||||
{
|
||||
using SHA512 sha = SHA512.Create();
|
||||
using FileStream? stream = File.OpenRead(filePath);
|
||||
byte[]? hash = await sha.ComputeHashAsync(stream);
|
||||
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static async Task<bool> ValidateHashAsync(string filePath, string hash)
|
||||
{
|
||||
return await CalculateHashAsync(filePath) == hash;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user