1. Below is the information of the file that will be used for the MD5 checksum (the CentOS ISO file is approximately 4.39 GB):
2. Make sure the file path in the Python script matches the actual location of the file.
E:\ISO\CentOS-7-x86_64-DVD-2009.iso
3. Run the script using PowerShell or CMD:
python scriptfile_name.py
4. MD5 checksum result (appears after about 88 seconds):
================================================
Sample Python Script
================================================
================================================
Related article (SHA Checksum):
================================================
# -*- coding: utf-8 -*-
"""
MD5 Checksum Generator for Large Files
Created on Sat Nov 1 2025
"""
import hashlib
def get_MD5(file_path):
"""
Calculate the MD5 checksum of a file in chunks.
Efficient for very large files (e.g. ISO, ZIP, etc.).
"""
chunk_size = 8192 # 8 KB per read
h = hashlib.md5()
with open(file_path, 'rb') as f:
while chunk := f.read(chunk_size):
h.update(chunk)
return h.hexdigest()
if __name__ == "__main__":
file_path = r"E:\ISO\CentOS-7-x86_64-DVD-2009.iso"
print("MD5 Checksum:", get_MD5(file_path))
================================================
Related article (SHA Checksum):
My Pocket : Python Script for SHA Checksum
Reference:
https://stackoverflow.com/questions/39276248/creating-an-md5-hash-of-a-zipfile
https://www.youtube.com/watch?v=a1P_9fGrfnU
Reference:
https://stackoverflow.com/questions/39276248/creating-an-md5-hash-of-a-zipfile
https://www.youtube.com/watch?v=a1P_9fGrfnU
Thank you.
Tidak ada komentar:
Posting Komentar