A password-based image protection utility for PNG files.
Version 9 introduces authenticated encryption behavior using an Encrypt-then-MAC design with HMAC-SHA256. Decryption is only performed after successful password verification, preventing silent corruption.
⚠️ Note: This tool uses a deterministic XOR stream cipher for pixel transformation. While authentication is strong, this is not a replacement for modern AEAD cryptography such as AES-GCM.
Before decryption occurs, the script verifies an HMAC-SHA256 tag embedded inside the PNG metadata. If:
The operation aborts safely without altering the file.
Uses:
pinlock-img-v9This slows down brute-force attacks and derives cryptographically strong keys from user passwords.
A single 32-byte master key is derived and split into:
numpy.random.default_rng() to produce a deterministic noise stream.This cleanly separates encryption and authentication responsibilities.
All writes occur via temporary files followed by shutil.move() to prevent partial writes or corruption in case of interruption.
Supports recursive directory scanning for processing entire PNG collections in one command.
password → PBKDF2 → 32-byte master key
Split into:
tEXt chunk under:pinlock_auth
This prevents:
Requires Python 3.8+
Install dependencies:
pip install numpy Pillow
⚠️ v9 supports PNG files only to ensure reliable metadata-based authentication.
python pinlock-img.py /path/to/png_or_directory
The script automatically determines whether each file should be encrypted or decrypted based on the .lock suffix.
Preview operations without modifying any files:
python pinlock-img.py /path/to/files
Enable Dry Run? (y/n): y
No password is required in dry run mode.
getpassExample:
Password:
Confirm Password:
✅ Encrypted: image1.lock.png
✅ Decrypted: secret_photo.png
❌ Wrong password (authentication failed): private.lock.png
========================================
📊 Batch Summary
========================================
Total Files Handled : 3
Encrypted : 1
Decrypted : 1
========================================
✨ Done!
However:
If higher-grade cryptographic guarantees are required, consider upgrading the transformation layer to an AEAD cipher.
Licensed under the MIT License.
See the LICENSE file for details.