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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap