This Python project allows you to hide secret messages within image files and then extract them back, using the Alpha (A) channel of RGBA images. It's a simple, yet effective, demonstration of steganography principles.
- Hide Message: Embeds text messages into the Alpha channel of a PNG image (converts to RGBA if not already).
- Extract Message: Reads hidden messages back from the modified image.
- Non-destructive to RGB: Preserves the original Red, Green, and Blue color components of the pixels. Only modifies the Alpha (transparency) channel.
- End-of-Message Indicator: Uses
0
(Null character ASCII/Unicode value) as a terminator to know where the hidden message ends. - Basic Input Validation: Ensures only valid alphanumeric and common punctuation characters are hidden.
- Python 3.x
- Pillow (PIL Fork): For image manipulation (opening, converting, reading/writing pixels, saving).
- Standard Python Built-ins:
ord()
,chr()
,"".join()
, etc.
- Make sure you have Python 3.x installed.
- Install the Pillow library:
pip install Pillow
- Save your code for hiding the message as
message_writer.py
. - Run the script from your terminal:
python message_writer.py
- Follow the prompts to:
-
Enter the full path to your input image (e.g.,
C:/path/to/my_image.png
). The image will be converted to RGBA if not already. -
Enter the secret message you wish to hide. The message should only contain common alphanumeric characters, spaces, and standard punctuation.
-
Enter the full path where you want to save the modified image (e.g.,
C:/path/to/hidden_message_image.png
).Important: It is highly recommended to save the output image in PNG format (.png). Formats like JPG/JPEG do not fully support the Alpha channel and may compress data, leading to loss of the hidden message.
-
- Save your code for extracting the message as
message_reader.py
. - Run the script from your terminal:
python message_reader.py
- Follow the prompt to:
- Enter the full path to the image containing the hidden message (the image saved by
message_writer.py
).
- Enter the full path to the image containing the hidden message (the image saved by
Here's a visual demonstration of the steganography process:
Original Image:
Hidden Message Image:
├── message_writer.py
├── message_reader.py
├── vortiqon_yt_logo.jpg
├── vortiqon_yt_logo_hidden.jpg
└── README.md
- Image Format: Best works with PNG images, as JPG/JPEG typically do not support Alpha channels reliably and may compress data, destroying the hidden message. It's highly recommended to use PNG for both input (if possible) and output.
- Message Length: The length of the message is limited by the number of pixels in the image that can store data (specifically, the Alpha channel of every 10th pixel in your current implementation). Ensure your message is shorter than the image's capacity.
- Character Set: Only characters with ASCII/Unicode values between 1 and 255 (excluding 0, which is the terminator) are supported.
- Stealth Level: This is a basic steganography implementation. While the RGB channels remain untouched, a forensic analysis might detect anomalies in the Alpha channel.
- GUI (Graphical User Interface): Implement a user-friendly graphical interface using libraries like Tkinter or PyQt.
- More Robust Error Handling: Enhance input validation and error messages.
- Multiple Hiding Methods: Explore other steganography techniques (e.g., LSB - Least Significant Bit manipulation in RGB channels).
- Performance Optimization: Improve the speed of pixel manipulation for larger images.
- Encryption: Add an encryption layer to the message before hiding it for better security.
Ahmadreza Haj Talebi - Aerospace Engineering student with a passion for programming and space.
Version: 1.0.0