A Python command-line utility for verifying file integrity using cryptographic hashes.
This is an active development project. While the core functionality is working, we plan to add several exciting features in the near future!
- Automatic detection of hash algorithms based on hash format
- Support for multiple cryptographic hash algorithms
- File integrity verification
- Clear and informative output
- Built-in error handling
- User-specified chunk size for file processing
- Support for additional hash algorithms
- Improved error reporting
- More detailed verification statistics
- Additional output formats
No installation required. The script uses Python's built-in hashlib module.
python hash_detector.py -f <file_path> -H <expected_hash>
or
py hash_detector.py -f <file_path> -H <expected_hash>
or if you have more than one python version
pythonx.xx hash_detector.py -f <file_path> -H <expected_hash>-f, --file: Path to the file you want to verify-H, --Hash: The expected hash value to verify against
python hash_detector.py -f example.txt -H 5d41402abc4b2a76b9719d911017c592The script automatically detects and supports the following hash algorithms:
- MD5 (32 hexadecimal characters)
- SHA-1 (40 hexadecimal characters)
- SHA-256 (64 hexadecimal characters)
- BLAKE2 (variable length)
- bcrypt (special format starting with
$2a$ ,$2b$ , or$2y$ )
Note: bcrypt is currently not supported for verification.
-
The script automatically detects the hash algorithm based on:
- For MD5: 32 hexadecimal characters
- For SHA-1: 40 hexadecimal characters
- For SHA-256: 64 hexadecimal characters
- For bcrypt: starts with
$2a$ ,$2b$ , or$2y$
-
If the hash format is not recognized, the script will exit with an error.
-
The script then:
- Reads the specified file in chunks
- Generates a hash using the detected algorithm
- Compares the generated hash with the provided expected hash
- Displays the verification result
The script will display:
- The detected hash algorithm
- The computed hash value
- The expected hash value
- A verification result indicating if the file is safe or not
The script handles the following error cases:
- Missing or inaccessible files
- Unsupported or unknown hash formats
- Invalid hash algorithms
- File processing errors
- 0: Success (hash verification completed)
- 1: Error (invalid hash format, file not found, etc.)
This tool is designed for file integrity verification. Always verify files from trusted sources. The script uses Python's built-in hashlib module for cryptographic operations.
- The
-aparameter is currently unused and will be ignored - bcrypt verification is not supported
- The script processes files in 64KB chunks by default
- Limited hash algorithm support
- Basic error reporting only
- Customizable chunk size for file processing
- Support for additional hash algorithms:
- SHA-3 family
- Argon2
- Scrypt
- PBKDF2
- More detailed verification statistics
- Multiple output formats
- Improved error handling and reporting
- Parallel processing for large files
- Unsupported hash algorithms
- Hash format mismatches
- File access errors
- 0: Success
- 1: Error (file not found, unsupported algorithm, etc.)
This tool is for file integrity verification. Always verify files from trusted sources.