PNG Steganography CLI is a command-line tool that allows you to hide a message within a PNG image using steganography techniques. It also incorporates a simple RSA encryption algorithm to encrypt the hidden message for added security.
Steganography is the practice of concealing information within other non-secret data to avoid detection. In this tool, a message is hidden by modifying the pixel data of a PNG image, making it appear unchanged to the human eye while containing the hidden information. When hiding a message, you can choose the number of bits to alter in each byte of the image. The available options are 1 to 4 bits. Using a higher number of bits provides more space for the message but also increases the chances of the alteration being detected.
The RSA encryption algorithm is a widely used public-key encryption method that utilizes the properties of prime numbers for secure data transmission. The hidden message is encrypted using a randomly generated public-private key pair, ensuring that only the intended recipient with the corresponding private key can decrypt and extract the message.
Note: The prime numbers used for generating RSA key pairs in this tool are not large enough for secure production use. They are provided for demonstration purposes only. For real-world applications, it is crucial to use much larger prime numbers to ensure the security of the encryption.
- Hide a message within a PNG image
- Extract a hidden message from a PNG image
- Python 3.6+
- NumPy library
- PIL (Python Imaging Library)
-
Clone the repository:
git clone https://github.com/alexandengstrom/png-steganography-cli.git
-
Navigate to the project directory:
cd png-steganography-cli
-
Install the required dependencies:
pip install -r requirements.txt
python3 png_steganography.py hide <source_image> <data_file> [--bits <num_bits>] [--output <output_image>]
- hide: Action to hide a message within a PNG image.
- <source_image>: Path to the source PNG image.
- <data_file>: Path to the file containing the message to be hidden
- --bits <num_bits>(optional): Number of bits to alter in each byte(1-4). Default is 1.
- --output <output_file>(optional): Output path for the new image. If not provided, the soruce image will be overwritten.
python3 png_steganography.py extract <source_image> <decryption_key> [--bits <num_bits>] [--output <output_file>]
- extract: Action to extract a hidden message from a PNG image.
- <source_image>: Path to the PNG image that stores the hidden message.
- <decryption_key>: Decryption key used to extract the message.
- --bits <num_bits>(optional): Number of bits used when the image was altered(1-4). Default is 1.
- --output <output_file>(optional): Path to a file where the extracted message should be saved. If not provided, the message will be printed to the console.
- Hiding a message within an image:
python3 png_steganography.py hide image.png secret.txt --bits 2 --output output.png
- Extracting a hidden message from an image:
python3 png_steganography.py extract image.png 12345-6789 --bits 2 --output extracted.txt
This is an example of how the entire novel Romeo & Juliet can be hidden inside an image.
Here we have the same image, but with "Romeo & Juliet" covertly hidden within. The image utilizes only one bit in every byte, specifically the least significant bit. This clever technique makes it incredibly challenging for the human eye to detect any differences. In fact, the variance is almost impossible to notice.
If we choose to utilize the last four bits of every byte instead, we begin to observe subtle changes in the sky. Additionally, it becomes possible to perceive the boundary where the hidden message concludes. As demonstrated, merely around one-seventh of the image is required to accommodate the entirety of the novel.
- Steganography: https://en.wikipedia.org/wiki/Steganography
- RSA Algorithm: https://en.wikipedia.org/wiki/RSA_(cryptosystem)