I need (paid) assistance to convert the following C# code written in Visual Studio to B4J.
This routine creates an SHA-1 hash, based on the filenames and contents on a small number of files located within a specified directory, with the exclusion of one particular file called ConfigKeys.json. I need to create this as part of a migration from Visual Studio to B4J. In order to match the code at the "other end", the method used in this C# code to make the SHA-1 hash must match, however I don't understand the use of TransformBlock and TransformFinalBlock as they apply to the iterative Hashing process.
Please let me know your "Donation" price - any offers considered
Kind regards,
Ralph Parkhurst
Melbourne, Australia
This routine creates an SHA-1 hash, based on the filenames and contents on a small number of files located within a specified directory, with the exclusion of one particular file called ConfigKeys.json. I need to create this as part of a migration from Visual Studio to B4J. In order to match the code at the "other end", the method used in this C# code to make the SHA-1 hash must match, however I don't understand the use of TransformBlock and TransformFinalBlock as they apply to the iterative Hashing process.
Original C# code:
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;
}
Please let me know your "Donation" price - any offers considered
Kind regards,
Ralph Parkhurst
Melbourne, Australia