Delphi Md5文件效验器 函数代码 (50分)

来源:百度知道 编辑:UC知道 时间:2024/06/30 18:36:26
function SameMD5(FileName,FileName2:String):Boolean
begin
Result:=Md5File(FileName)=Md5File(FileName2);
end;

Function Md5File(FileName:String):String;
begin
xxxxxx
end;

Md5File 函数如何写?

参考函数:
procedure TForm1.DoCalc;
const
cnBufferSize = 16384;
var
i, j: integer;
InputFile: TFileStream;
FileName: string;
FileSize: Int64;
CurrentSize: Int64;
TotalSize: Int64;
Buffer: pointer;
BufferString: string;
VisibleString: string;
NewStep, OldStep: integer;
Context: MD5Context;
Digest: MD5Digest;
begin
SetLength (BufferString, cnBufferSize);
Buffer := Addr (BufferString[1]);
try
// try
for i := 0 to ListBox1.Items.Count-1 do
begin
ListBox1.ItemIndex := i;
Application.ProcessMessages;
if UserAbort then Abort;

if FileExists (ListBox1

md5 算法你看看怎么样,改改应该你就可以用了

unit Md5;

interface

uses SysUtils, Classes, Controls;

Const
S11 = 7;
S12 = 12;
S13 = 17;
S14 = 22;
S21 = 5;
S22 = 9;
S23 = 14;
S24 = 20;
S31 = 4;
S32 = 11;
S33 = 16;
S34 = 23;
S41 = 6;
S42 = 10;
S43 = 15;
S44 = 21;

type
TSourceType = (SourceFile, SourceByteArray, SourceString);
ULONG32 = record
LoWord16: WORD;
HiWord16: WORD;
end;
PULONG32 = ^ULONG32;
PLong = ^LongInt;
hashDigest = record
A: Longint;