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?

3
  • 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). Commented May 10, 2016 at 1:42
  • 2
    FWIW, here's the source: hg.python.org/cpython/file/2.7/Objects/stringobject.c#l1262 Commented May 10, 2016 at 1:44
  • python hash is not cryptographic purpose, use real crypto library. Commented May 10, 2016 at 1:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.