MD5文件哈希 - 使用PHP md5_file函数匹配Delphi输出 [英] MD5 File Hashing - match Delphi output with PHP md5_file function
问题描述
函数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一个
比较您的结果:
-
md5(file_get_contents())
PHP -
命令行程序md5(1)aka
md5sum(1)
如果除了一个人同意这个总和,那么你知道在哪里挖。
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:
md5(file_get_contents( ))
in PHPhash("md5", )
from the PHP hash framework extensionthe command line programs md5(1) aka md5sum(1)
If all but one agree what the sum is, then you know where to dig.
这篇关于MD5文件哈希 - 使用PHP md5_file函数匹配Delphi输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!