##getMd5.py
import os,sys
import md5
import hashlib
########################################
def Get_Md5_Of_String(src):
md1 =hashlib.md5()
md1.update(src)
return md1.hexdigest()
########################################
def Get_Md5_Of_File(filename):
if not os.path.isfile(filename):
return
myhash = hashlib.md5()
f = file(filename,'rb')
while True:
b = f.read(8096)
if not b :
break
myhash.update(b)
f.close()
return myhash.hexdigest()
########################################
def Get_Md5_Of_Folder(dir):
MD5File = "tmp.md5"
outfile = open(MD5File,'w')
for root, subdirs, files in os.walk(dir):
for file in files:
filefullpath = os.path.join(root,file)
filerelpath = os.path.relpath(filefullpath,dir)
md5 = Get_Md5_Of_File(filefullpath)
outfile.write(md5)