If I have a file that I want to monitor for any changes (other than looking at the file date stamps etc).
How could I perform a SHA1 hash on its contents?
I think this is what GIT does, so I just want to learn how to do it
using (FileStream stream = File.OpenRead(@"C:\File.ext"))
{
using (SHA1Managed sha = new SHA1Managed())
{
byte[] checksum = sha.ComputeHash(stream);
string sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
}
}
Calculate the checksum periodically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With