Pyntegrity is Python package that helps you check a file integrity.
Tested on:
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
Latest version is 1.2.0
To install Pyntegrity use pip:
pip install pyntegrity
The supported checksum algorithms are:
- md5
- sha256
- sha512
For now mostly small files since it loads the whole file in memory to calculate its checksum
In your program import the class IntegrityValidator:
from pyntegrity.core import IntegrityValidatorInitialize it with the target file and the expected checksum (it automatically detects which checksum algorithm to use), example:
obj = IntegrityValidator(
str_path="my_file.txt",
checksum_str="my_checksum",
)Then use the function validate_file_integrity to check the file integrity,
it returns True if the target file checksum equal the one passed in the class constructor,
if else it returns False, example:
status = obj.validate_file_integrity()Right now it will open anyfile in text mode (even binary).
- Support more file type modes
- Support more checksum algorithms
- Support for big files
GPL-3.0 see license content