MD5 Hashing in Python

We has MD5 Hash a String in Python by making use of the hashlib module.


Example:

import hashlib

plain_text = "Code2care - Lines of Code for a Change!"

md5_hash = hashlib.md5()
md5_hash.update(plain_text.encode('utf-8'))

hash_text = md5_hash.hexdigest()

print(f"Original Text: {plain_text}")
print(f"MD5 Hash Text: {hash_text}")
Output:
Original Text: Code2care - Lines of Code for a Change!
MD5 Hash Text: bfbd6b895caf3e43609b9da0b13004e3
Python MD5 Hasing Example

Documentation:
  1. hashlib — Secure hashes and message digests
  2. MD5 Wikipedia
  3. RFC 1321 - The MD5 Message-Digest Algorithm

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!