Forked from neoneo40/How_to_make_hash_in_python2_and_python3.md
Created
February 18, 2020 20:49
-
-
Save AdilsonFuxe/b884fc61abadf51b4b423a98297b8a96 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