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

问题描述

我需要一个4字符的散列。目前我正在采用 md5()哈希的前4个字符。我正在对80个字符或更少的字符串进行哈希处理。这会导致碰撞吗?或者,碰撞的可能性是多少?假设我将散列少于65,536(16 )的不同元素?

解决方案

正如您从(公式来自),只有几百个元素,您的碰撞概率超过50%。



当然,如果您面临攻击者提供字符串的可能性,那么您可以假设它是100% - 在任何现代PC上几乎可以瞬间完成扫描以发现16位搜索空间中的冲突。甚至任何现代手机,就此而言。

I need a 4-character hash. At the moment I am taking the first 4 characters of a md5() hash. I am hashing a string which is 80 characters long or less. Will this lead to collision? or, what is the chance of collision, assuming I'll hash less than 65,536 (16) different elements?

解决方案

Surprisingly high indeed. As you can see from this graph of an approximate collision probability (formula from the wikipedia page), with just a few hundred elements your probability of having a collision is over 50%.

Note, of course, if you're facing the possibility of an attacker providing the string, you can probably assume that it's 100% - scanning to find a collision in a 16-bit search space can be done almost instantaneously on any modern PC. Or even any modern cell phone, for that matter.

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

06-26 21:32