Skip to content

Instantly share code, notes, and snippets.

@antonydevanchi
Created June 14, 2021 22:33
Show Gist options
  • Save antonydevanchi/6613f776065d8a3ab6099a6c1d6cc677 to your computer and use it in GitHub Desktop.
Save antonydevanchi/6613f776065d8a3ab6099a6c1d6cc677 to your computer and use it in GitHub Desktop.
How to get MD5 sum of a string using python?
import hashlib
m = hashlib.md5()
m.update("whatever your string is")
print m.hexdigest()
# Code is awesome.
# You can do it in dozens different ways and always wrong.
# Ha-ha!
import hashlib
print hashlib.md5("whatever your string is").hexdigest()
# Code is awesome.
# You can do it in dozens different ways and always wrong.
# Ha-ha!
import hashlib
print(hashlib.md5("whatever your string is".encode('utf-8')).hexdigest())
# Code is awesome.
# You can do it in dozens different ways and always wrong.
# Ha-ha!
# What you think?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment