python3

python3 md5对大文件的处理

小樊
83
2024-06-14 16:41:27
栏目: 编程语言

import hashlib

def md5_large_file(file_path): md5 = hashlib.md5() with open(file_path, “rb”) as f: for chunk in iter(lambda: f.read(4096), b""): md5.update(chunk)

return md5.hexdigest()

file_path = “large_file.txt” md5_hash = md5_large_file(file_path) print(f"MD5 hash of the file {file_path}: {md5_hash}")

0
看了该问题的人还看了