0

我需要创建一个程序,为目录中的每个文件创建哈希签名。我需要输出包含它旁边的文件名和哈希。

这是我到目前为止的代码,它所做的就是给我哈希值。

import os, hashlib

path = "/home/ec2-user/environment"

for filename in os.listdir(path):
    if not os.path.isdir(filename):

        hasher = hashlib.md5()
    with open('39802.jpeg', 'rb') as afile:
        buf = afile.read()
    hasher.update(buf)
    print(hasher.hexdigest())
4

0 回答 0