文件MD5校验和 [英] File MD5 checksum
本文介绍了文件MD5校验和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这个问题中提到了wcrypt2。
In this question is mentioned the wcrypt2.
我需要的只是计算一个文件的MD5。如果我可以计算它而不必保存它是完美的,因为它是以流格式下载的文件。
What I need is simply calculate the MD5 of a file. It would be perfect if I could calculate it without having to save it because it is a downloaded file in stream format.
我想要最直接的方法
谢谢!
推荐答案
这是一个工作代码Indy 10:
Here is a working code for Indy 10:
function MD5File(const FileName: string): string;
var
IdMD5: TIdHashMessageDigest5;
FS: TFileStream;
begin
IdMD5 := TIdHashMessageDigest5.Create;
FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
Result := IdMD5.HashStreamAsHex(FS)
finally
FS.Free;
IdMD5.Free;
end;
end;
问候,
OscaR1
Regards, OscaR1
这篇关于文件MD5校验和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文