A robust C implementation of LSB (Least Significant Bit) steganography for hiding secret text files within BMP images.
StegoBMP allows you to securely hide confidential text files inside BMP images without any visible changes to the image. The program uses LSB steganography to encode data into the least significant bits of image pixels, making the hidden data virtually undetectable to the human eye.
- Encode: Hide any text file inside a 24-bit BMP image
- Decode: Extract hidden files from stego images
- Magic String Protection: Use custom passwords to secure your hidden data
- Automatic Extension Preservation: Original file extensions are maintained during decoding
- Capacity Validation: Checks if the image can hold the secret file before encoding
- Error Handling: Comprehensive validation and error reporting
- Algorithm: LSB (Least Significant Bit) Steganography
- Supported Format: 24-bit BMP images only
- Language: C
- Platform: Cross-platform (Linux, macOS, Windows with appropriate compiler)
The program modifies the least significant bit of each pixel's color values (RGB) to encode data. Since changes to LSBs produce minimal visual differences, the modifications are imperceptible to human eyes.
Encoding Structure:
- BMP Header (54 bytes) - Copied unchanged
- Magic String - Custom password for verification
- File Extension Length (32 bits)
- File Extension (e.g., ".txt")
- Secret File Size (32 bits)
- Secret File Data (encoded bit by bit)
- Remaining Image Data (copied unchanged)
- GCC compiler or any C compiler
- Basic knowledge of command line operations
- BMP image files (24-bit)
- Text files for encoding
- Clone the repository:
git clone https://github.com/SLADE0261/StegoBMP.git
cd StegoBMP- Compile the project:
gcc main.c encode.c decode.c -o stegobmpOr use the provided Makefile (if available):
makeBasic Syntax:
./stegobmp -e <input_image.bmp> <secret_file.txt> <magic_string>With Custom Output Name:
./stegobmp -e <input_image.bmp> <secret_file.txt> <output_image.bmp> <magic_string>Examples:
# Encode secret.txt into input.bmp with magic string "#*"
# Output will be saved as output_image.bmp (default)
./stegobmp -e input.bmp secret.txt "#*"
# Encode with custom output filename
./stegobmp -e input.bmp secret.txt stego.bmp "myPassword123"Decoding (Extracting Hidden File)
Basic Syntax:
./stegobmp -d <stego_image.bmp> <magic_string>With Custom Output Name:
./stegobmp -d <stego_image.bmp> <output_name> <magic_string>Examples:
# Decode from stego.bmp using magic string "#*"
# Output will be saved as output_text.txt (default)
./stegobmp -d stego.bmp "#*"
# Decode with custom output filename (extension auto-added)
./stegobmp -d stego.bmp decoded "myPassword123"
# Creates: decoded.txtStegoBMP/
├── main.c # Main program entry point
├── encode.c # Encoding implementation
├── encode.h # Encoding function declarations
├── decode.c # Decoding implementation
├── decode.h # Decoding function declarations
├── types.h # Custom type definitions
└── README.md # This file
- Image Format: Only 24-bit BMP images are supported
- File Type: Currently optimized for text files, but can handle any file type
- Magic String: Must be identical for encoding and decoding
- Capacity: The image must have sufficient capacity to hold the secret file
- Output Extension: When decoding, do not include file extension in output name
The image must have enough pixels to store:
- Magic string
- File extension length (4 bytes)
- File extension
- Secret file size (4 bytes)
- Secret file content
Formula:
Required Capacity = (Magic String Length + Extension Length + 8 + Secret File Size) × 8 bits
Available Capacity = Image Width × Image Height × 3 bytes
# 1. Prepare files
# - input.bmp (source BMP image)
# - secret.txt (file to hide)
# 2. Encode the secret
./stegobmp -e input.bmp secret.txt output.bmp "SecurePass"
# Output: SUCCESS: do_encoding function completed
# 3. Share output.bmp (appears as normal image)
# 4. Decode the secret
./stegobmp -d output.bmp extracted "SecurePass"
# Output: SUCCESS: do_decoding function completed
# Creates: extracted.txt (with original content)| Error | Meaning | Solution |
|---|---|---|
| Not enough arguments | Missing required parameters | Check command syntax |
| Incorrect input file type | File is not .bmp | Use 24-bit BMP images only |
| Incorrect secret file type | File is not .txt | Use text files |
| Unable to open file | File not found or no permission | Check file path and permissions |
| Magic String not found | Wrong magic string used | Use the correct magic string from encoding |
| Capacity check failed | Image too small for secret | Use a larger image |
- The magic string acts as a password - keep it secure
- LSB steganography is detectable through statistical analysis
- For higher security, encrypt your secret file before encoding
- Use high-resolution images for better hiding capacity
- Avoid using the same magic string repeatedly
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
This project is open source and available for educational purposes.
Krishnakant C. Pore
- LSB Steganography technique
- BMP file format specification
- C programming community
- Support for PNG and JPEG formats
- GUI interface
- Encryption integration
- Multi-file encoding
- Password strength validation
- Compression before encoding
- Progress indicators for large files
GitHub: https://github.com/SLADE0261/StegoBMP
★ If you find this project useful, please consider giving it a star!