hash randomisation
Mixing a secret random value, chosen when a process starts, into string hashing so that hash values cannot be predicted from outside.
In more detail
Python has randomised str, bytes and datetime hashes by default since version 3.3, which is why hash('apple') differs between runs. Integers are not randomised, so their hashes stay the same across runs. Randomisation defeats hash flooding only while the seed stays secret; if attackers can observe hash outputs, a keyed hash such as SipHash is needed.
Related terms
- PYTHONHASHSEED — The environment variable that controls the seed Python uses to randomise str, bytes and datetime hashes.
- hash flooding — An attack that sends a server many keys crafted to collide in its hash tables, turning each O(1) operation into O(n) and exhausting its CPU.
- SipHash — A fast keyed hash function designed so that, without the secret key, attackers cannot predict or engineer collisions.
- random seed — The starting value of a pseudo-random number generator; the same seed always produces the same sequence of numbers.
Taught in
- What A Hash Function Promises — Algorithms & Data Structures for Working Engineers
- Collisions In Practice And Hash Flooding — Algorithms & Data Structures for Working Engineers