[英]Why is one function for an MD5 hash calculation preferable for smaller files yet inefficient for large files?
I am working on generating hash values for files as a means of disallowing duplicate files in a small database.我正在为文件生成 hash 值,作为在小型数据库中禁止重复文件的一种手段。 As I was researching, I found the following thread: How to generate an MD5 checksum for a file in Android?
在我研究的过程中,我发现了以下线程: How to generate an MD5 checksum for a file in Android?
Why is the first answer "not efficient" for large files and it is best for small strings, whereas the answer provided by dentex
is better-suited for large files?为什么第一个答案对于大文件“效率不高”并且最适合小字符串,而
dentex
提供的答案更适合大文件? Is it because of the way the solution was programmed, or is there a caveat with MD5 hashing that I am unaware of?是因为解决方案的编程方式,还是我不知道 MD5 散列有一个警告?
MD5 generates a 128-bit digest. MD5生成一个 128 位的摘要。
SHA-1 generates a 160-bit digest. SHA-1生成一个 160 位的摘要。
SHA-2 generates a 224-, 256-, 384- or 512-bit digest. SHA-2生成 224、256、384 或 512 位摘要。
More bits means more distinct values, means less likelihood of a two distinct inputs generating the same digest.更多位意味着更多不同的值,意味着两个不同输入生成相同摘要的可能性更小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.