1

In the MIT OpenCourseWare YouTube lecture on hashing, the professor gives an example of two strings causing a hash collision in Python:

>>> hash('\0B')
64
>>> hash('\0\0C')
64

Why does this happen?

Alex Huszagh
  • 13,272
  • 3
  • 39
  • 67
SeanPlusPlus
  • 8,663
  • 18
  • 59
  • 84
  • I edited the question to use the Python2.x tag rather than Python, since this is specific to Python 2. With the introduction of a `PYTHONHASHSEED` in Python 3.x, the hashes for both are not the same (and will vary run to run). – Alex Huszagh May 10 '16 at 01:42
  • 2
    FWIW, here's the source: https://hg.python.org/cpython/file/2.7/Objects/stringobject.c#l1262 – mgilson May 10 '16 at 01:44
  • python hash is not cryptographic purpose, use real crypto library. – YOU May 10 '16 at 01:46

0 Answers0