将分割文件的 MD5 结果与整个文件的 MD5 进行比较
我遇到一种情况,我有一个非常大的文件,我正在使用 linux“split”命令将其分成更小的部分。后来我使用linux“cat”命令将所有部件重新组合在一起。
然而,在此期间,我很好奇...
如果我在分割大文件之前获得 MD5 指纹,然后在分割命令产生的所有独立文件部分上获取 MD5 指纹,有没有办法获取独立的指纹并以某种方式推断出它们各部分的总和或平均值(或者您喜欢的所有内容)等于单个大文件的指纹?
通过(非常)松散的示例...
bigoldfile.txt MD5 = 737da789
smallfile1.txt MD5 = 23489a89
smallfile2.txt MD5 = 1238g89d
smallfile3.txt MD5 = 01234cd7
someoperator(23489a89,1238g89d,01234cd7) = 737da789(原始文件的指纹)
I have a situation where I have one VERY large file that I'm using the linux "split" command to break into smaller parts. Later I use the linux "cat" command to bring the parts all back together again.
In the interim, however, I'm curious...
If I get an MD5 fingerprint on the large file before splitting it, then later get the MD5 fingerprints on all the independent file parts that result from the split command, is there a way to take the independent fingerprints and somehow deduce that the sum or average (or whatever you like to all it) of their parts is equal to the fingerprint of the single large file?
By (very) loose example...
bigoldfile.txt MD5 = 737da789
smallfile1.txt MD5 = 23489a89
smallfile2.txt MD5 = 1238g89d
smallfile3.txt MD5 = 01234cd7
someoperator(23489a89,1238g89d,01234cd7) = 737da789 (the fingerprint of the original file)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能无法做到这一点 - MD5 内部足够复杂,并且取决于实际数据以及“初始”哈希值。
您可以改为生成“增量”哈希值 - 第一部分的哈希值、第一部分加第二部分的哈希值等。
You likely can't do that - MD5 is complex enough inside and depends on actual data as well as the "initial" hash value.
You could instead generate "incremental" hashes - hash of first part, hash of first plus second part, etc.
不完全是,但下一个最好的办法是这样做:
cat 文件部分1 文件部分2 | md5和
或者
cat 文件部分* | md5sum
确保以正确的顺序将它们重新组合在一起。
通过管道传输 cat 的输出,您不必担心创建太大的组合文件。
Not exactly but the next best thing would be to do this:
cat filepart1 filepart2 | md5sum
or
cat filepart* | md5sum
Be sure to cat them back together in the correct order.
by piping the output of cat you don't have to worry about creating a combined file that is too large.