Last active
January 30, 2021 01:47
-
-
Save neoneo40/a6ff3a988b4e67297efc to your computer and use it in GitHub Desktop.
How to make md5 and sha1 in python3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank bro. It is really helpful )