本文介绍了结合MD5哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当计算在一个大文件中的单个MD5校验,什么技术一般用于各种的MD5值结合成一个单一的值?你只需添加它们放在一起?我没有在任何特定的语言,库或API,它会做到这一点真的很感兴趣;而我在它背后的技术,只是有兴趣。有人可以解释它是如何做?

鉴于伪code以下算法:

  MD5Digest X
为每个文件F段
   MD5Digest Y = CalculateMD5(F)
   结合(X,Y)
 

但究竟会联合吗?它是否添加两个MD5摘要在一起,还是什么?

解决方案

考虑到这一点,你不希望结合两MD5哈希值。通过的任意的MD5的实现,你有保持当前校验状态的对象。所以,你可以提取的MD5校验在任何时候,散列共享相同的开头两个文件时,这是非常方便的。对于大文件,你只要保持数据反馈 - 有没有区别,如果你哈希文件一次或块,作为国家被记住。在这两种情况下,你会得到相同的哈希值。

When calculating a single MD5 checksum on a large file, what technique is generally used to combine the various MD5 values into a single value? Do you just add them together? I'm not really interested in any particular language, library or API which will do this; rather I'm just interested in the technique behind it. Can someone explain how it is done?

Given the following algorithm in pseudo-code:

MD5Digest X
for each file segment F
   MD5Digest Y = CalculateMD5(F)
   Combine(X,Y)

But what exactly would Combine do? Does it add the two MD5 digests together, or what?

解决方案

With that in mind, you don't want to "combine" two MD5 hashes. With any MD5 implementation, you have a object that keeps the current checksum state. So you can extract the MD5 checksum at any time, which is very handy when hashing two files that share the same beginning. For big files, you just keep feeding in data - there's no difference if you hash the file at once or in blocks, as the state is remembered. In both cases you will get the same hash.

这篇关于结合MD5哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:20