md5sum calculation by python

# md5sum.pyy
import re
import clipboard
import os
import cv2
import numpy as np
import hashlib


# Finding Md5 of Files Recursively in Directory in Python - GeeksforGeeks: https://www.geeksforgeeks.org/finding-md5-of-files-recursively-in-directory-in-python/
def md5(file_path):
    # Calculate the MD5 hash of a file.
    with open(file_path, 'rb') as f:
        file_hash = hashlib.md5()
        while chunk := f.read(8192):
            file_hash.update(chunk)
    return file_hash.hexdigest()


text = clipboard.paste()
lsA = text.splitlines()

# print(lsA)
for idx, ff in enumerate(lsA):
    ff = ff.replace('"', "")
    ff = ff.replace("'", "")

    chk_sum = md5(ff)
    print(f"idx {idx:6d} / {len(lsA)} : {chk_sum} {ff}")

os.system("pause")

posted on 2024-08-23 00:33  yusisc  阅读(4)  评论(0编辑  收藏  举报

导航