Hide a text file inside a lossless image (e.g., PNG) using the provided image_lsb.py
script.
- Steganography is the embedding of a message in another medium.
- Least Significant Bit (LSB) steganography does this by modifying the least significant bits of pixel values to store data.
- Python 3.9+
- Install dependencies:
pip install pillow numpy
image_lsb.py
β the steganography scriptcover.png
β your input (lossless) imagesecret.txt
β the text you want to hidestego.png
β the output image containing hidden data
echo "This is my secret message" > secret.txt
python image_lsb.py hide cover.png secret.txt stego.png
Arguments
cover.png
β input image (use PNG or another lossless format)secret.txt
β the file to embedstego.png
β output image with embedded payload
Step 3: Extract the Hidden Text Later
python image_lsb.py extract stego.png recovered.txt
cat recovered.txt
Arguments
stego.png
β image with embedded payloadrecovered.txt
β output file for the extracted text
- Use lossless formats (PNG). JPEG re-encoding will destroy simple LSB data.
- For better secrecy, encrypt or compress the text before embedding so the bit pattern appears random.
- The cover image must be large enough: it needs 8 bits per payload byte plus a small header.
- The visual appearance of
stego.png
should be identical tocover.png
to the naked eye.