Delphi获取MD5值

//获取文件的MD5值
function TForm1.GetFileMD5(var path:string):string;
var filemd5:TIdHashMessageDigest5;
begin
    filemd5:=TIdHashMessageDigest5.Create;    //必须先初始化
    result:=filemd5.AsHex(filemd5.HashValue(TFileStream.Create(path,fmOpenRead)));
    filemd5.Free;   //最后必须释放对象
end;

//获取文本MD5值
function GetMD5Hash(Str:String):String;
var
   md5 : TIdHashMessageDigest5;
   longWordRec : T4x4LongWordRecord;
begin
   md5 := TIdHashMessageDigest5.Create;
   longWordRec:=md5.HashValue(Trim(Str)); //加密
   Result:= md5.AsHex(longWordRec);
   md5.Free;
end;