MD5文件哈希 - 使用PHP md5_file函数匹配Delphi输出 [英] MD5 File Hashing - match Delphi output with PHP md5_file function

查看:156
本文介绍了MD5文件哈希 - 使用PHP md5_file函数匹配Delphi输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数MD5(const fileName:string):我正在使用这个代码在Delphi 7中的md5哈希:串; 
var
idmd5:TIdHashMessageDigest5;
fs:TFileStream;
begin
idmd5:= TIdHashMessageDigest5.Create;
fs:= TFileStream.Create(fileName,fmOpenRead OR fmShareDenyWrite);
try
result:= idmd5.AsHex(idmd5.HashValue(fs));
finally
fs.Free;
idmd5.Free;
结束
结束

我正在尝试将输出与PHP函数相同

  md5_file()

我已经看了一下,常见的问题似乎是编码,而不是填零,但是我不知道如何使用TIdHashMessageDigest5或者它们是否已经在函数中完成。



如果任何人有任何他们使用的功能,它将非常感激!



或者可能是一种将php功能更改为匹配Indy一个

解决方案

比较您的结果:





如果除了一个人同意这个总和,那么你知道在哪里挖。


I'm currently using this code for md5 hashing in Delphi 7:

function MD5(const fileName : string) : string;
var
  idmd5 : TIdHashMessageDigest5;
  fs : TFileStream;
begin
  idmd5 := TIdHashMessageDigest5.Create;
  fs := TFileStream.Create(fileName, fmOpenRead OR fmShareDenyWrite) ;
  try
    result := idmd5.AsHex(idmd5.HashValue(fs)) ;
  finally
    fs.Free;
    idmd5.Free;
  end;
end;

and I'm trying to get the output the same as the PHP function

md5_file()

I've had a look around and common problems seem to be encoding and not padding with zeroes, but I don't know how to do either of these using TIdHashMessageDigest5 or whether they are already done in the function.

If anyone has any functions they use for this it'd be very appreciated!

Or possibly a way of changing the php function to match the Indy one

解决方案

Compare your results with:

If all but one agree what the sum is, then you know where to dig.

这篇关于MD5文件哈希 - 使用PHP md5_file函数匹配Delphi输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆