Created
November 1, 2017 08:44
-
-
Save songpon/5f6896343121dd45a6141d301a6f16d2 to your computer and use it in GitHub Desktop.
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
import hashlib | |
def check_sum(data): | |
# if type dict need to cast to string | |
if type(data)==type({}): | |
data = str(data) | |
# lib require to encode to unicode before hash | |
hash_object = hashlib.md5(data.encode()) | |
return hash_object.hexdigest() | |
#test | |
print(check_sum('{"key":"value"}')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment