Replace built-in hash function with hashlib.

The built-in hash function returns inconsistent values in Python 3.