import os
import hashlib

hash = hashlib.sha256()
fh = None
try:
    fh = open("/mnt/container_storage/webapp/vmp/malwaredb/parser/malware_detail.html", "w")
    fh.write('<table style="width:100%">\n')
    for root, dirs, files in os.walk("/home/profile/malware"):
        for f in files:
            o = "<tr><td>"
            o += str(os.path.join(root, f))
            #print(os.path.join(root, f))
            o += "</td><td>"
            with open(os.path.join(root, f), 'rb') as afile:
                while True:
                  buf = afile.read(65536)
                  if not data:
                    break
                  hash.update(buf)
            o += str(hash.hexdigest())
            #print(hash.hexdigest())
            o += "</td></tr>"
            fh.write(o)
    fh.write('</table>')
finally:
    if fh != None:
        fh.close()    

