文件哈希 [英] File Hashing

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

问题描述

我在想(并希望有人能够回答这个问题):


如果我计算文件的哈希值(MD5或SHA1),我可以吗?确保:


1)具有相同散列值的两个文件实际上是相同的吗?


2)两个不同的文件永远不会有相同的哈希值?


3)如果两个文件具有相同的MD5哈希值,它们也将具有相同的哈希值b / b $ b SHA1哈希值(我认为总会如此)?


TIA,

Johnny J.

I''m wondering (and hoping that somebody will be able to answer this):

If I calculate the hash value of files (either MD5 or SHA1), can I then be
sure that:

1) Two files with the same hash value are in fact identical?

2) Two different files will NEVER have the same hash value?

3) If two files have the same MD5 hash value, they will ALSO have the same
SHA1 hash value (I should think that will always be the case)?

TIA,
Johnny J.

推荐答案

Johnny J?rgensen写道:
Johnny J?rgensen wrote:

我想知道(并希望有人能够回答这个):


如果我计算文件的哈希值(MD5或SHA1),那么我可以确定:

确保:


1)具有相同散列值的两个文件实际上是相同的?
I''m wondering (and hoping that somebody will be able to answer this):

If I calculate the hash value of files (either MD5 or SHA1), can I then be
sure that:

1) Two files with the same hash value are in fact identical?



不,但相当肯定。

No, but fairly sure.


2)两个不同的文件永远不会有相同的哈希值?
2) Two different files will NEVER have the same hash value?



不,但相当肯定。

No, but fairly sure.


3)如果两个文件具有相同的MD5哈希值,他们也会有相同的

SHA1哈希值(我认为总会如此)?
3) If two files have the same MD5 hash value, they will ALSO have the same
SHA1 hash value (I should think that will always be the case)?



不,但相当肯定。


- Barry


- -
http://barrkel.blogspot.com/


请不要在语言组之间交叉发布。

滥用是一回事带有非语言.NET问题的C#新闻组(我们都是这样做的,每次都是
:))。但是如果您的.NET问题在C#新闻组中名义上是名义上的主题

(凭借您正在使用的语言),它肯定是

在VB.NET新闻组中偏离主题,反之亦然。


mpdlcsharp的后续行动。


至于问题,你最好在这个新闻组中搜索

关键词,如hash,same,file等等。你会对'br'感到惊讶/>
已经在主题上说过(特别是关于你的前两个问题)。


但是,简短的版本是:


2008年5月28日星期三11:44:27 -0700,Johnny J ?? rgensen< jo ** @ altcom.se>

写道:
Please do not cross-post between language groups. It''s one thing to
"abuse" the C# newsgroup with non-language .NET questions (we all do it
all the time :) ). But if your .NET question is even nominally on-topic
in the C# newsgroup (by virtue of the language you''re using), it''s
definitely off-topic in the VB.NET newsgroup, and vice a versa.

Follow-ups to m.p.d.l.csharp.

As for the question, you would do well to search this newsgroup for
keywords like "hash", "identical", "file", etc. You''d be amazed at what''s
already been said on the topic (especially on your first two questions).

But, the short version is:

On Wed, 28 May 2008 11:44:27 -0700, Johnny J??rgensen <jo**@altcom.se>
wrote:

我想知道(并希望有人能够回答这个问题):


如果我计算文件的哈希值(MD5或SHA1) ),我可以



肯定:


1)两个文件机智h相同的哈希值实际上是相同的吗?


2)两个不同的文件永远不会有相同的哈希值?
I''m wondering (and hoping that somebody will be able to answer this):

If I calculate the hash value of files (either MD5 or SHA1), can I then
be
sure that:

1) Two files with the same hash value are in fact identical?

2) Two different files will NEVER have the same hash value?



你的前两个问题是相同的,所以两者的答案是

相同:不,你不能确定。

Your first two questions are the same, and so the answer for both is the
same: no, you cannot be sure of that.


3)如果两个文件具有相同的MD5哈希值,它们也将具有相同的



SHA1哈希值(我认为总会如此)?
3) If two files have the same MD5 hash value, they will ALSO have the
same
SHA1 hash value (I should think that will always be the case)?



当然,我不是加密专家。但是,我会说这个答案是

也是不。如果MD5提供的功能与SHA1差不多,

即使它是128位而SHA1是160位,那么为什么有人会为SHA1打扰?b $ b b b?不,我认为可以说至少有一些文件,其中MD5哈希是相同的,但是SHA1哈希值不是



当然,找到两个不同的文件在

中生成完全相同的哈希算法要么是人为的,要么是非常困难的。但是,它仍然是一种可能性(见问题#1和#2的答案)。 :)


Pete

Granted, I''m not a crypto expert. However, I''d say the answer to this is
also "no". If MD5 provided just as much differentiating power as SHA1,
even though it''s 128 bits while SHA1 is 160 bits, then why would anyone
bother with SHA1? No, I think it''s safe to say that there are at least
some pairs of files for which the MD5 hash is identical, but the SHA1 hash
is not.

Of course, finding two different files that produce the exact same hash in
either algorithm is either contrived or very difficult. But then, it''s
still a possibility (see the answer to questions #1 and #2). :)

Pete


5月28日,8:44 * pm,Johnny J?rgensen < j ... @ altcom.sewrote:
On May 28, 8:44*pm, "Johnny J?rgensen" <j...@altcom.sewrote:

我想知道(并希望有人能够回答这个问题):


如果我计算文件的哈希值(MD5或SHA1),那么我可以确定:


1 )具有相同散列值的两个文件实际上是相同的吗?


2)两个不同的文件永远不会有相同的散列值?


3)如果两个文件具有相同的MD5哈希值,它们也将具有相同的

SHA1哈希值(我认为情况总是如此)?


TIA,

Johnny J.
I''m wondering (and hoping that somebody will be able to answer this):

If I calculate the hash value of files (either MD5 or SHA1), can I then be
sure that:

1) Two files with the same hash value are in fact identical?

2) Two different files will NEVER have the same hash value?

3) If two files have the same MD5 hash value, they will ALSO have the same
SHA1 hash value (I should think that will always be the case)?

TIA,
Johnny J.



你好,


所有散列函数都有一组有限的返回值(比如:2 ^ 128)

但是有无数个可能的输入值。这显然意味着两个输入值可以产生相同的输出值




但实际上,你可以找到两个输入值的概率

生成相同的哈希签名非常接近于零。我会

说:


1)是的。它将是同一个文件(好吧,大部分时间,请阅读:
http://www.mathstat.dal.ca/~selinger/md5collision/

2)是。

3)否使用MD5和SHA-1实际上会减少可能发生碰撞的数量。

Hello,

All hashing functions have a finite set of return values (say : 2^128)
but an infinite number of possible input values. This clearly implies
that two input values CAN generate the same output value.

But in practice, the probability that you can find two input values
generating the same hash signature are pretty close to zero. I would
say :

1) Yes. It will be the same file (well, most of the time, read this :
http://www.mathstat.dal.ca/~selinger/md5collision/)
2) Yes.
3) No. Using both an MD5 and a SHA-1 will in fact reduce the number of
possible collisions.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆