Minggu, 19 April 2020

Python Script for MD5 Checksum

Python script for MD5 checksum of large files.

Sample Script
================================================

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 22:51:22 2020

"""

from Crypto.Hash import MD5


def get_MD5(file_path):

    chunk_size = 8192

    h = MD5.new()

    with open(file_path, 'rb') as f:
        while True:
            chunk = f.read(chunk_size)
            if len(chunk):
                h.update(chunk)
            else:
                break

    return h.hexdigest()

print (get_MD5("D:\path\path\path.zip")) 

================================================

Reference:
https://stackoverflow.com/questions/39276248/creating-an-md5-hash-of-a-zipfile
https://www.youtube.com/watch?v=a1P_9fGrfnU