Python Hash

Just a kindly reminder that Python built-in hash() uses random seed in some specific version, that leads to different hash value from the same input in different sessions.

See questions and comments here.

You can use export PYTHONHASHSEED=1 or fixed integer seed to avoid the randomness, or using import hashlib module, for example:

1
2
3
4
import hashlib
hash_output = hashlib.md5("input".encode()).hexdigest()
# or usign differet algorithm
hash_output = hashlib.sha256("input".encode()).hexdigest()
0%