thinking of AES encryption as putting your image in a secure digital safe, try this repo
This project focuses on encrypting and decrypting images using the Advanced Encryption Standard (AES) algorithm in Python. The implementation utilizes the Pillow
library for image processing and the pycryptodome
library for AES encryption. The encryption is done in Cipher Block Chaining (CBC) mode, and a random key and Initialization Vector (IV) are generated for enhanced security.
Ensure that you have the required libraries installed before running the code:
pip install Pillow
pip install pycryptodome
The main script, main.py
, encompasses the following functionalities:
- Validates image files
- Generates a random key and IV
- Derives a password-based key using PBKDF2
- Calculates HMAC for data integrity
Execute the script by navigating to the directory where main.py
is saved and using the following command:
python main.py
The second script, image_crypto.py
, provides a simplified approach to image encryption and decryption using the pycryptodome
module. However, this script is currently not working as intended.
- Run the
main.py
script and provide the path to the image when prompted. - The script will generate a random key and IV, encrypt the image, and save the encrypted image.
- After encrypting an image with
main.py
, use the provided key and IV to decrypt the image using themain.py
script.
If you encounter issues with the image_crypto.py
script, consider reviewing and adjusting the code based on specific requirements. Thoroughly test the script with various scenarios to ensure correct functionality.
This example assumes the use of a random 128-bit key for AES encryption. In a real-world scenario, key management is crucial, and secure methods for key generation, storage, and exchange should be considered.
Feel free to adapt the code based on your project's requirements and conduct extensive testing to ensure its reliability.