0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 08:30:45 -05:00

22 lines
597 B
C#
Raw Normal View History

2024-06-18 17:35:31 -04:00
using System.Security.Cryptography;
2024-12-31 13:46:44 -05:00
namespace ReCodeItLib.Utils;
2024-06-18 17:35:31 -04:00
internal static class HashUtil
{
/// <summary>
/// Create a file hash from an inputed file
/// </summary>
/// <param name="filePath"></param>
/// <returns>A file hash</returns>
public static string GetFileHash(string filePath)
{
using var sha256 = SHA256.Create();
using var stream = File.OpenRead(filePath);
byte[] hashBytes = sha256.ComputeHash(stream);
var hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
return hash;
}
}