Skip to content

Instantly share code, notes, and snippets.

@re4lfl0w
Last active January 30, 2021 01:47
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save re4lfl0w/a6ff3a988b4e67297efc to your computer and use it in GitHub Desktop.
Save re4lfl0w/a6ff3a988b4e67297efc to your computer and use it in GitHub Desktop.
How to make md5 and sha1 in python3.
# python3
from hashlib import md5
def make_md5(s, encoding='utf-8'):
return md5(s.encode(encoding)).hexdigest()
print(make_md5(s, encoding='utf-8'))
# 9e107d9d372bb6826bd81d3542a419d6
print(len(make_md5(s, encoding='utf-8')))
# 32
# python3
from hashlib import sha1
def make_sha1(s, encoding='utf-8'):
return sha1(s.encode(encoding)).hexdigest()
print(make_sha1(s, encoding='utf-8'))
# 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
print(len(make_sha1(s)))
# 40
@Clever91
Copy link

Thank bro. It is really helpful )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment