文件 MD5 校验和
In this question is mentioned the wcrypt2.
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.
I would like to have the most straightforward way to do that.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
这是 Indy 10 的工作代码:
问候,
奥斯卡R1
Here is a working code for Indy 10:
Regards,
OscaR1
基于@dummzeuch 的回答,我写了这个函数:
Based on @dummzeuch answere I wrote this function:
Indy 附带了计算多种哈希值的函数,MD5 就是其中之一。 至少从 Delphi 2006 开始,Indy 就包含在所有版本的 Delphi 中,并且可以免费下载旧版本。
Indy comes with functions for calculating several hashes, MD5 is one of them. Indy is included in all versions of Delphi since at least Delphi 2006 and available as a free download for older versions.
关于什么:
What about:
正如您提到的,您链接到的帖子讨论了
wcrypt2
,这是一个加密例程库,包括 MD5。 您链接到的帖子似乎也表明它可用于 Delphi 7,因为询问者包含标记为“Delphi 7”的输出。 您已将此问题标记为delphi7
,因此我假设您也正在使用该版本。 那么是什么阻止您使用wcrypt2
呢?该问题链接到 wcrypt2.pas 的副本,该文件中的版权日期似乎表明该单元在 Delphi 7 发布时可用。 检查您的安装; 你可能已经拥有了。 如果没有,那么该单位还说它是通过Project Jedi获得的,所以你可以尝试看看单位也有。
您所引用问题的答案包括示例 Delphi 代码以及 Delphi 附带的用于执行 MD5 的单元名称。 它们随 Delphi 2009 一起提供,因此您应该检查它们是否也适用于您的版本。
As you mentioned, the post you linked to talks about
wcrypt2
, which is a library of cryptographic routines, including MD5. The post you linked to also seems to indicate that it is available for Delphi 7 since the asker includes output labeled "Delphi 7." You have tagged this questiondelphi7
, so I assume that's the version you're using, too. So what's stopping you from usingwcrypt2
?The question links to a copy of wcrypt2.pas, and the copyright dates in that file appear to indicate that the unit was available by the time Delphi 7 was released. Check your installation; you might already have it. If not, then the unit also says that it was obtained via Project Jedi, so you could try looking there for the unit as well.
The answers to your referenced question include example Delphi code and the names of units that come with Delphi for doing MD5. They come with Delphi 2009, so you should check whether they're also available for your version.
看一下 Delphi 中 MD5SUM 的这个实现。 它需要一个字符串作为输入,但我想你可以轻松地使其与流一起工作。
Take a look at this implementation of MD5SUM in Delphi. It requires a string for input, but I imagine you can easily make it work with a stream.
MessageDigest_5 也适用于此。
MessageDigest_5 would work for this as well.
我在 Delphi 7 和 Indy 10.1.5 中使用以下函数
I use the following function in Delphi 7 with Indy 10.1.5
如果您使用 Overbyte http://www.overbyte.eu/frame_index.html 只需添加单位并使用文件名调用函数 FileMD5
If you use Overbyte http://www.overbyte.eu/frame_index.html just add unit and call function FileMD5 with name of file