-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Issue Summary
Brute-force decryption logic in the image encryption module suffers from inconsistencies in shuffling, incorrect pixel mapping, and serious performance issues in pixel_decoder.py
Issue Description
Double Shuffle Desync:
During decryption, both new_y and new_x are shuffled independently, while encryption likely used a consistent or sequential coordinate system. This inconsistency leads to improper image reconstruction.
Shuffling Order Mismatch:
Without knowing whether the image was encrypted using row-first, column-first, or flattened order, assuming both axes were shuffled randomly may result in mismatched decryption.
Incorrect Re-mapping Logic:
In the current brute-force approach:
reconstructed[y][x] = img[i][j]
This is logically reversed. It should instead follow:
reconstructed[i][j] = img[y][x]
This restores each pixel to its original position instead of assigning it incorrectly.
Image.show() in Loop:
Opening the image in a loop for each seed leads to hundreds of preview windows, overwhelming the system and hindering usability.
Performance Inefficiency:
Saving and displaying the image on every iteration consumes significant I/O and memory, especially during brute-force decryption across a wide seed range.
Proposed Solution (Optional)
1.)Use a consistent shuffling logic during encryption and store the shuffle map (indices).
2.)Implement a proper reverse mapping using index tracking.
3.)Replace image.show() in loops with seed logging or hash checking.
4.)Optionally preview only when a certain condition (e.g., perceptual hash similarity or user-defined threshold) is met.
5.)Optimize performance by avoiding I/O-heavy operations unless the result is likely to be correct.
Priority
High - Requires urgent attention
Category
- Enhancement
- Refactor
- Security
- Design
- Other
Additional Context (Optional)
Hi Maintainers,
I'm a GSSoC'25 contributor with 2+ years of experience in Python and have worked extensively on image processing and cryptographic utilities. While analyzing the decryption logic in pixel_decoder.py, I noticed the current implementation could significantly benefit from restructuring and bug resolution.
The brute-force decryption strategy lacks consistency with the encryption shuffle logic, which breaks accurate reconstruction. Furthermore, the current loop-based rendering and image preview logic (image.show()) makes the process both memory-heavy and impractical for real-world testing. A few lines of code, such as the remapping logic, are also reversed or non-functional under the current coordinate assumptions.
I would love to contribute a robust solution that:
Aligns encryption and decryption processes through reproducible shuffling.
Implements a clean reverse mapping mechanism.
Replaces expensive GUI operations with intelligent seed validation (e.g., perceptual hash comparisons or checksum-based checks).
Ensures readability, modularity, and PEP8 compliance throughout the affected files.
Looking forward to your response and hoping to submit a PR after your feedback.
Best regards,
Sansriti Mishra
GSSoC'25 Contributor