A Python tool for hiding and extracting messages in images using DCT (Discrete Cosine Transform) steganography. My implementation modifies DCT coefficients in the frequency domain to embed data with minimal visual impact on the image.
DCT (Discrete Cosine Transform) steganography is a technique that hides information within the frequency components of an image rather than directly manipulating pixel values.
- Secure Message Hiding: Embed text messages within images with minimal visual changes
- Extraction: Recover hidden messages from steganographic images
- Configurable Strength: Adjust embedding strength to balance between robustness and visual quality
- Command-Line Interface: Easy-to-use CLI for both embedding and extraction operations
- Grayscale Image Support: Works with grayscale images (can be extended to color)
- Null Termination: Messages are automatically null-terminated for reliable extraction
- Python 3.6+
- NumPy
- OpenCV (cv2)
- SciPy
- Clone this repository:
git clone https://github.com/murugnn/dct-steganography.git
cd dct-steganography
- Install the required dependencies:
pip install -r requirements.txt
To hide a message in an image:
python dct_steganography.py embed --image path/to/cover.png --message "Your secret message or flag{hidden_data}" --output path/to/output.png
Optional parameters:
--alpha
or-a
: Embedding strength (default: 0.1). Higher values make the embedding more robust but potentially more visible.
To extract a hidden message from an image:
python dct_steganography.py extract --image path/to/stego.png
Optional parameters:
--length
or-l
: Specify the message length in bits if known (usually not needed as messages are null-terminated)
This project is fully Dockerized so you can run it without installing any dependencies directly on your machine.
- Docker installed and running
- xorg-xhost
Build the docker image:
docker build -t stegapp .
Run the container and embed a message(completely for Linux X11 users):
xhost +local:docker && \
docker run --rm -it \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $(pwd):/app \
stegapp embed \
-i original.png \
-m "Your secret message or flag{hidden_data}" \
-o output.png && \
xhost -local:docker
To extract a message:
docker run -it -v $(pwd):/app stegapp extract --image output.png
- CTF Challenges: Hide flags within images for capture-the-flag competitions
- Digital Watermarking: Embed copyright information in images
- Covert Communication: Exchange hidden messages within innocuous-looking images
- Data Authentication: Verify the integrity of images
- Color image support (applying DCT to each color channel)
- Adaptive embedding strength based on image content
- Error correction codes for more robust recovery
- Encryption of the message before embedding
- Spread spectrum techniques for increased security
This project is licensed under the MIT License