If you need to get the MD5 sum of a string using Python, then you can do the following.

Step 1

Firstly, we need to use the hashlib module:

1
import hashlib

Step 2

Now make sure that the input string is encoded correctly.

1
your_input = "this is your input string".encode('utf-8')

Step 3

Finally use the md5 function of the hashlib module, and get the hexdigest() value from it:

1
hashlib.md5(your_input).hexdigest()

Putting it all together

1
2
3
4
5
6
7
8
import hashlib

your_input = "this is your input string".encode('utf-8')
hashed = hashlib.md5(your_input).hexdigest()

print(hashed)

# --> af0874120fd6196ea1feeebdb6de0e54