delphi GetFileHashMD5获取文件 HashMD5值


本文整理自网络,侵删。

 
单元文件 System.Hash

function GetFileHashMD5(FileName: String): String;
var
HashMD5: THashMD5;
begin
  HashMD5 := THashMD5.Create;
  BufLen := 16 * 1024;
  Buffer := AllocMem(BufLen);
  try
    Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
    try
      while Stream.Position < Stream.Size do
      begin
        Readed := Stream.Read(Buffer^, BufLen);
        if Readed > 0 then
        begin
          HashMD5.update(Buffer^, Readed);
        end;
      end;
    finally
      Stream.Free;
    end;
  finally
    FreeMem(Buffer)
  end;

  result := HashMD5.HashAsString;
end;

相关阅读 >>

Delphi中使用 twebbrowser 编辑网页

Delphi中带缓存的数据更新技术

win7下使用Delphi7的方法

Delphi xe6调用android手机标准功能

Delphi完美的线程注入和卸载

Delphi 如何从文本内容中删除指定行

Delphi showmodal与show的区别

Delphi tclientdataset的使用

Delphi 串口控制继电器

Delphi firedac 的recordcount 相关测试 记录

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...