private string Encrypt_Folder(string path)
{
string HashString;
var files = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly).ToList();
files.Sort(StringComparer.Ordinal);
// Remove the configKeys.json if it is in the list
files.RemoveAll(u => u.Contains("configKeys.json"));
SHA1 Hash = SHA1.Create();
Hash.Initialize();
for (int i = 0; i < files.Count; i++)
{
string file = files[i];
Console.WriteLine(file);
string fileName = Path.GetFileName(file);
byte[] pathBytes = Encoding.UTF8.GetBytes(fileName);
Hash.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0);
byte[] contentBytes = File.ReadAllBytes(file);
if (i == files.Count - 1)
Hash.TransformFinalBlock(contentBytes, 0, contentBytes.Length);
else
Hash.TransformBlock(contentBytes, 0, contentBytes.Length, contentBytes, 0);
}
HashString = BitConverter.ToString(Hash.Hash).Replace("-", "").ToUpper();
return HashString;
}