散列冲突和追加数据 [英] hash collision and appending data

查看:216
本文介绍了散列冲突和追加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个字符串(或字节数组)A和B,它们都具有相同的散列(散列,我的意思是像MD5或SHA1)。如果我连接在它后面的另一个字符串,A + C和B + C是否也具有相同的散列H'? C + A和C + B会发生什么?



我用

这是否正确(对于所有输入)?

所有(众所周知的)散列函数都是如此?如果不是,是否有一个(众所周知的)散列函数,其中A + C和B + C不会发生冲突(并且C + A和C + B也不会)?

(除了 MD5(x + reverse(x))以及其他构造的东西)

>解决方案

这完全取决于散列函数 。此外,您碰到这些碰撞的可能性非常小。


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屋!

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