这里的问题是一次
SHA256Managed读取4096个字节(继承
FileStream并重写
Read(byte[], int,int)以查看它从文件流中读取了多少字节),这对于磁盘IO而言太小了。
为了加快速度(2分钟,我的机器SHA256,1分钟MD5哈希上2
GB的文件)裹
FileStream在
BufferedStream,并设置合理大小的缓冲区大小(我试过〜1 MB缓存):
// Not sure if BufferedStream should be wrapped in using blockusing(var stream = new BufferedStream(File.OpenRead(filePath), 1200000)){ // The rest remains the same}


