I'm trying to write some code to get the md5 of every exe file in a folder.
My problem is that I don't understand how to do it. It works only if the folder contains only one file. This is my code:
import glob
import hashlib
file = glob.glob("/root/PycharmProjects/untitled1/*.exe")
newf = str (file)
newf2 = newf.strip( '[]' )
newf3 = newf2.strip("''")
with open(newf3,'rb') as getmd5:
data = getmd5.read()
gethash= hashlib.md5(data).hexdigest()
print gethash
And I get the result:
a7f4518aae539254061e45424981e97c
I want to know how I can do it to more than one file in the folder.