I wanted to create a checksum of a file I currently store locally. Within the files contents I will need to checksum the body of the file only excluding the first and last line (header and footer). The headers and footers always begin with >>
I have currently implemented code in c# to generate the checksum but that generates it for all the files contents. I currently have two options either generate this within c# code or generate it using command prompt on windows.
My current c# code looks something like this:
string CalculateMD5(string fileLocation)
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(fileLocation))
{
var hash = md5.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", "");
}
}
}
Also I have tried using this cmd command: Certutil -hashfile filename.txt MD5
Again this generates the MD5 value for the whole file which is not the required output.
p.s. I did try removing first and last line using c# and then generating the md5 hash, however the value seemed to differ from what it should be.
Any and all suggestions welcome :)
Thanks