散列冲突和追加数据 [英] hash collision and appending data
问题描述
这完全取决于散列函数 。此外,您碰到这些碰撞的可能性非常小。
Assume I have two strings (or byte arrays) A and B which both have the same hash (with hash I mean things like MD5 or SHA1). If I concatenate another string behind it, will A+C and B+C have the same hash H' as well? What happens to C+A and C+B?
I tested it with MD5 and in all my tests, appending something to the end made the hash the same, but appending at the beginning did not.
Is this always true (for all inputs)?
Is this true for all (well-known) hash functions? If no, is there a (well-known) hash function, where A+C and B+C will not collide (and C+A and C+B do not either)?
(besides from MD5(x + reverse(x))
and other constructed stuff I mean)
This depends entirely on the hash function. Also, the probability that you have those collisions is really small.
这篇关于散列冲突和追加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!