Lesson 28: File Integrity Checker

This script checks if a file has been modified.

import hashlib

def file_hash(filename):
  with open(filename, "rb") as f:
    data = f.read()
  return hashlib.md5(data).hexdigest()

print(file_hash("data.txt"))

Used in security monitoring systems.

Next Lesson →