Issue 13710: hash() on strings containing only null characters returns the length of the strings (original) (raw)

Issue13710

Created on 2012-01-04 04:58 by Ramchandra Apte, last changed 2022-04-11 14:57 by admin. 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
2022-04-11 14:57:25 admin set github: 57919
2012-01-04 05:14:51 jcea set nosy: + jceamessages: +
2012-01-04 05:05:24 benjamin.peterson set status: open -> closednosy: + benjamin.petersonmessages: + resolution: rejected
2012-01-04 05:02:10 Ramchandra Apte set title: 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:49 Ramchandra Apte set title: 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:50 Ramchandra Apte create