试图在文件夹中找到匹配的md5哈希

时间:2017-10-29 08:40:01

标签: python python-2.7 python-3.x

我试图编写程序来搜索ffile文件夹中的md5哈希文件以匹配特定的哈希值。请帮忙!

import hashlib

 from hashlib import md5
    hash_file = raw_input ()
    afile = open('ffile','rb')
    buf = afile.read ()

1 个答案:

答案 0 :(得分:0)

import os
hash_to_find = '5c583fd40360fd039b3ac98387b77dbb'
for i in os.listdir('.'):
    if os.path.isfile(i):
         with open(i,'rb') as f:
             for line in f:
                 if line.startswith(hash_to_find):
                     print(i)             
                     break