Creating MD5 files with Python
- Using Powershell to calculate/compare MD5 hashes
- Using Powershell to create MD5 files
- Using Python to compute a MD5 Hash
- Creating MD5 files with Python
Here’s the probably last part of this series, the missing piece showing the calculation of MD5 files with Python:
# http://www.pythoncentral.io/hashing-files-with-python/ import hashlib import os import codecs hasher = hashlib.md5() def calcHash(filename): print("Filename: " + filename) with open(filename, 'rb') as afile: buf = afile.read() hasher.update(buf) print("Calculated: " + hasher.hexdigest()) md5file = (os.path.splitext(filename)[0]) + ".md5" writeMD5 = codecs.open(md5file, "wb", "utf-8-sig") writeMD5.write(hasher.hexdigest()) calcHash("e:/arara.log") |