Use hashlib.md5 in Python 3.
import hashlib
source = '000005fab4534d05api_key9a0554259914a86fb9e7eb014e4e5d52permswrite'.encode()
md5 = hashlib.md5(source).hexdigest() # returns a str
print(md5) # a02506b31c1cd46c2e0b6380fb94eb3d
If you need byte type output, use digest()
instead of hexdigest()
.