#计算字符串md5值
def get_str_md5(str):
myMd5 = hashlib.md5() myMd5.update(str)
myMd5_Digest = myMd5.hexdigest()
return myMd5_Digest
#计算文件md5值
def get_md5(file_name):
with open(file_name) as file_to_check:
data = file_to_check.read()
md5_returned = hashlib.md5(data).hexdigest()
return md5_returned
网友评论