Google tag

Pages

Delphi7实现MD5


delphi7里带了标准的MD5算法,单元文件IdHashMessageDigest.pas

例子:

uses
  IdHashMessageDigest;//MD5计算

function MD5(CheckStr:string):String; //CheckStr为待加密的文件路路径。
var
  MyMD5: TIdHashMessageDigest5;
begin
  
  MyMD5:=TIdHashMessageDigest5.Create;
  Result:=MyMD5.AsHex(MyMD5.HashValue(TFileStream.Create(CheckStr,fmOpenRead or fmSharedenyNone))); 
  
  MyMD5.Free; 

end;


No comments: