A command-line steganography application that hides secret messages within images using the LSB (Least Significant Bit) technique. Developed as part of the Programming in C and C++ Languages (PJC) course at PJATK, Winter 2022/2023.
This tool allows you to hide and extract secret messages within image files without visibly altering the image. It supports BMP and PPM image formats and uses a robust LSB steganography algorithm that modifies the two least significant bits of each color channel.
- Message Encryption - Hide text messages within images
- Message Decryption - Extract hidden messages from images
- Multi-format Support - Works with BMP (24-bit) and PPM (ASCII) formats
- Capacity Check - Verify if your message fits in the image
- Image Information - Display detailed image metadata
- ASCII Art UI - Beautiful command-line interface with ASCII art
- Error Handling - Comprehensive error messages and validation
Format | Description | Extension |
---|---|---|
BMP | 24-bit Bitmap images | .bmp |
PPM | ASCII-encoded Portable PixMap | .ppm |
The project follows the MVC (Model-View-Controller) pattern:
- Models
Image
- Abstract base class for image handlingBmp
- BMP format implementationPpm
- PPM format implementationMessage
- Steganography algorithm implementationPixels
- Pixel manipulation utilities
- Controllers
BaseController
- Main application controllerFlagController
- Command-line flag parsingArgumentController
- Command execution logic
- View
CommandLineInterface
- User interface with ASCII art
- C++14 or higher
- CMake 3.23 or higher
- Command line interface
- Clone the repository:
git clone https://github.com/yourusername/image-steganography-cpp.git
cd image-steganography-cpp
- Create build directory and compile:
mkdir build
cd build
cmake ..
make
Or use CMake directly:
cmake -B build
cmake --build build
After building, the executable will be in the build
directory:
./build/steganography
steganography [options] <path-to-image>
steganography [options] <path-to-image> "message-to-encrypt"
Flag | Long Form | Description | Example |
---|---|---|---|
-h |
--help |
Display help information | steganography -h |
-i |
--info |
Show image information | steganography -i image.bmp |
-e |
--encrypt |
Hide message in image | steganography -e image.bmp "Secret message" |
-d |
--decrypt |
Extract message from image | steganography -d image.bmp |
-c |
--check |
Check encryption capacity | steganography -c image.bmp "Test message" |
steganography -e beach.bmp "This is my secret message!"
2. Extract a Hidden Message
steganography -d beach.bmp
steganography -i beach.bmp
Output:
.------..------..------..------.
|I.--. ||N.--. ||F.--. ||O.--. |
| (\/) || :(): || :(): || :/\: |
| :\/: || ()() || ()() || :\/: |
| '--'I|| '--'N|| '--'F|| '--'O|
`------'`------'`------'`------'
File path: beach.bmp
File format: .bmp - 24 bit per pixel.
Image resolution: 1920 x 1080
Image size: 6220800 bytes
Last modification time: Tue Dec 20 15:30:00 2022
steganography -c image.ppm "Can this message fit?"
The tool uses the Least Significant Bit (LSB) technique to hide messages:
- Message Encoding:
- Prepends a "size" flag (4 bytes) and message length (4 bytes)
- Converts the message to binary
- Modifies the 2 least significant bits of each color channel (RGB)
- Distributes bits across pixels to minimize visual impact
- Message Decoding:
- Reads the flag to verify an encoded message exists
- Extracts the message length
- Reconstructs the message from the modified bits
Each pixel can store 6 bits of data (2 bits per color channel):
- Red channel: bits 0-1
- Blue channel: bits 2-3
- Green channel: bits 4-5
- Messages are not encrypted - only hidden
- No password protection
- Can be detected by steganalysis tools
- Original image is modified (though imperceptibly)
For sensitive data, consider encrypting your message before hiding it.
The maximum message length (in bytes) is calculated as:
max_length = ((width Γ height Γ 3) - 64) Γ· 8
Where 64 bits are reserved for the header (flag + size).
- Fast encoding/decoding (O(n) where n = number of pixels)
- Minimal memory footprint
- Supports large images (tested up to 4K resolution)
The tool includes comprehensive error handling for:
- Invalid file paths
- Unsupported formats
- Messages too large for the image
- Corrupted image files
- Missing encoded messages
This project was developed as part of the Programming in C and C++ Languages (PJC) course at the Polish-Japanese Academy of Information Technology (PJATK) during the winter semester of 2022/2023.
- Advanced C++ programming techniques
- File I/O and binary manipulation
- Image format parsing
- Command-line interface design
- Software architecture patterns (MVC)
This is an academic project. Feel free to use it as a reference for learning, but please write your own implementation if you're working on a similar assignment.
Krzysztof Przybysz
Student ID: s24825
Course: Programming in C and C++ Languages (PJC)
Semester: Winter 2022/2023