Python 字串/檔案 取得 MD5

文字取得 md5:
    
def get_string_md5(string):
    return hashlib.md5(string.encode()).hexdigest()
    

檔案取得 md5:
    
def get_file_md5(file_patch):
    with open(file_patch, "rb") as f:
        return hashlib.md5(f.read()).hexdigest()
    

留言