python计算md5值

#计算字符串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

你可能感兴趣的:(python计算md5值)