MD5 and SHA1 Hash in Python

Let’s see how can we calculate the MD5 and the SHA1 hash value of a String in Python.

import hashlib
 
def MD5_Hash(plain=None):
	return hashlib.md5(plain).hexdigest()
 
def SHA1_Hash(plain=None):
	return hashlib.sha1(plain).hexdigest()
 
print (MD5_Hash(b"Hello there!"))
print (SHA1_Hash(b"Hello there!"))

That’s it!

Categories: Python Tags: , , ,
%d bloggers like this: