我将如何对文件执行 SHA1 哈希? [英] how would I perform a SHA1 hash on a file?
本文介绍了我将如何对文件执行 SHA1 哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个文件要监视任何更改(除了查看文件日期戳等).
If I have a file that I want to monitor for any changes (other than looking at the file date stamps etc).
如何对其内容执行 SHA1 哈希?
How could I perform a SHA1 hash on its contents?
我认为这就是 GIT 所做的,所以我只想学习如何去做
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);
}
}
定期计算校验和.
这篇关于我将如何对文件执行 SHA1 哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文