make it resilent against restarts/reloads remove all user interaction for resource gathering compute hashes on first time file resolving and on updates of said file on resolving
23 lines
695 B
C#
23 lines
695 B
C#
using System;
|
|
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace MareSynchronos.Utils
|
|
{
|
|
public class Crypto
|
|
{
|
|
public static string GetFileHash(string filePath)
|
|
{
|
|
using SHA1CryptoServiceProvider cryptoProvider = new();
|
|
return BitConverter.ToString(cryptoProvider.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "");
|
|
}
|
|
|
|
public static string GetHash(string stringToHash)
|
|
{
|
|
using SHA1CryptoServiceProvider cryptoProvider = new();
|
|
return BitConverter.ToString(cryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToHash))).Replace("-", "");
|
|
}
|
|
}
|
|
}
|