Just a quick note on the syntax change needed if using Python 3. Previous versions of hashlib would accept string literals as input, but now you have to specify that the string is converted to bytes. This is accomplished by putting a 'b' just before the string you want to hash. Below is an example:
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hash = hashlib.md5(b"TEXT TO HASH").hexdigest()