/directory-validator

This repository contains scripts to verify the integrity of directories.

Primary LanguagePythonGNU Affero General Public License v3.0AGPL-3.0

Directory Validator

This Python script provides a simple yet effective way to create a stamp (a unique hash value) for a directory, which can then be used to validate the directory's contents later on. It's designed to detect any changes in the structure or contents of the directory.

Features

  • Create Stamp: Generate a unique hash for the entire directory, considering all files and subdirectories, except for the stamp file itself.
  • Validate Directory: Compare the current state of the directory against the stored hash value to detect any changes.

Usage

First, ensure you have Python installed on your system. Then, use the script from the command line as follows:

To create a stamp for a directory:

python directory_validator.py <path_to_directory> --stamp

To validate a directory:

python directory_validator.py <path_to_directory> --validate

How It Works

  • The script walks through the directory, generating a cumulative SHA-256 hash of all file and directory paths.
  • The generated hash, along with the current date and time, is stored in a file named directory_stemp.json within the directory.
  • For validation, the script recalculates the current directory's hash and compares it with the stored hash.

Author

Kevin Veen-Birkenbach

Repository

This script is maintained at GitHub.

Acknowledgments

This script was developed with the assistance of ChatGPT. You can find the conversation that led to this script here.


Feel free to contribute to this project or suggest improvements. For any issues or questions, please open an issue on the GitHub repository.