You can do the following:
Python 2.x
import hashlib
print hashlib.md5("whatever your string is").hexdigest()
Python 3.x
import hashlib
print(hashlib.md5("whatever your string is".encode('utf-8')).hexdigest())
However in this case you're probably better off using this helpful Python module for interacting with the Flickr API:
... which will deal with the authentication for you.
Official documentation of hashlib