classification
Title: hash() on strings containing only null characters returns the length of the strings
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Ramchandra Apte, benjamin.peterson, jcea
Priority: normal Keywords:

Created on 2012-01-04 04:58 by Ramchandra Apte, last changed 2012-01-04 05:14 by jcea. This issue is now closed.

Messages (3)
msg150587 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-01-04 04:58
If you run hash on strings containing only null characters it returns the length of the string
>>> hash("\0")
1
>>> hash("\0\0")
2
>>> hash("\0"*1000)
1000
This behaviour is not like proper hash functions.
The hashes of these strings should exhibit the avalanche effect like in a proper hash function.
msg150588 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-01-04 05:05
No. Python's dictionary implementation is designed to handle hash functions with the properties of Python's.
msg150590 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-01-04 05:14
Object hashes are not crypto hashes. Use hashlib module for crypto.
History
Date User Action Args
2012-01-04 05:14:51jceasetnosy: + jcea
messages: + msg150590
2012-01-04 05:05:24benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg150588

resolution: rejected
2012-01-04 05:02:10Ramchandra Aptesettitle: hash() on string containing only null characters returns the length of the strings -> hash() on strings containing only null characters returns the length of the strings
2012-01-04 05:01:49Ramchandra Aptesettitle: hash() on string containing only null characters returns the length of the string -> hash() on string containing only null characters returns the length of the strings
2012-01-04 04:58:50Ramchandra Aptecreate