[issue13703] Hash collision security issue

Frank Sievertsen report at bugs.python.org
Wed Jan 25 22:34:39 CET 2012


Frank Sievertsen <python at sievertsen.de> added the comment:

For the sake of completeness:
Collision-counting (with Exception) has interesting effects, too.

>>> d={((1<<(65+i))-2**(i+4)): 9 for i in range(1001)}
>>> for i in list(d): 
...  del d[i]

>>> d
{}
>>> 9 in d
False
>>> 0 in d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'too many slot collisions'
>>> d[9] = 1
>>> d
{9: 1}
>>> d == {0: 1}
False
>>> {0: 1} == d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'too many slot collisions'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13703>
_______________________________________


More information about the Python-bugs-list mailing list