Delphi:如何计算大文件的SHA哈希

编程入门 行业动态 更新时间:2024-10-23 15:31:36
本文介绍了Delphi:如何计算大文件的SHA哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在5 Gig文件上生成SHA。

Hi I need to generate a SHA over a 5 Gig file

您知道基于非字符串的Delphi库吗?

Do you know of a non string based Delphi library that can do this ?

推荐答案

您应使用 DCPcrypt v2 并读取缓冲的文件,并使用缓冲区为SHA哈希器提供数据,直到您读取完整的5GB文件为止。

You should use DCPcrypt v2 and read your file buffered and feed the SHA hasher with the buffer until you've read the complete 5GB file.

如果您想知道如何读取已缓冲的大文件,请参阅我的答案有关使用自定义缓冲的文件副本。

If you want to know how to read a large file buffered, see my answer about a file copy using custom buffering.

所以在概念上(没有真正的delphi代码!):

so in concept (no real delphi code!):

function GetShaHash(const AFilename: String) begin sha := TSHAHasher.Create; SetLength(Result, sha.Size); file := OpenFile(AFilename, GENERIC_READ); while not eof file do begin BytesRead := ReadFile(file, buffer[0], 0, 1024 * 1024); sha.Update(buffer[0], BytesRead); end; sha.Final(Result[0]); CloseFile(file); end;

更多推荐

Delphi:如何计算大文件的SHA哈希

本文发布于:2023-11-03 12:38:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555156.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大文件   Delphi   哈希   SHA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!