Hide secrets in plain sight. A command-line tool written in C that invisibly embeds and extracts secret files inside 24-bit BMP images using the Least Significant Bit (LSB) technique — pixel-perfect and visually undetectable.
Each bit of your secret file is embedded into the Least Significant Bit of the image's pixel bytes. Since the human eye cannot detect a 1-bit change in color intensity, the stego image looks 100% identical to the original.
Original pixel byte: 1 1 0 1 0 1 1 [0]
Secret bit embedded: 1 1 0 1 0 1 1 [1] ← Only LSB changes
- 🔐 A magic string
#*is embedded during encoding and verified during decoding to authenticate stego images - 🖼️ The output image retains the exact same dimensions, format, and visual quality
- ⚡ Works at the bit level — fast, lightweight, no external libraries needed
| Feature | Description |
|---|---|
| 📥 Encode | Hide any file (.txt, .c, .sh, .h) inside a BMP image |
| 📤 Decode | Extract hidden files from stego images |
| 📏 Capacity Check | Validates image size before encoding to prevent overflow |
| 🔑 Magic String Auth | #* marker ensures only valid stego images are decoded |
| 🗂️ Multi-format Support | Supports multiple secret file types |
| 🖼️ Lossless Quality | Original image dimensions and visual quality fully preserved |
LSB-Steganography/
├── 📄 main.c # Entry point — handles encode/decode routing
├── 📄 main.h # Enums: OperationType, Status, uint
├── 📄 encode.c # Full encoding logic
├── 📄 encode.h # EncodeInfo struct and encoding function declarations
├── 📄 decode.c # Full decoding logic
├── 📄 decode.h # DecodeInfo struct and decoding function declarations
├── 📄 common.h # Shared constants (magic string)
├── 📄 types.h # User-defined types (Status, uint)
├── 🖼️ beautiful.bmp # Sample source BMP image for testing
├── 🔒 secret.txt # Sample secret file for encoding test
└── 📝 output.txt # Output file after decoding
- GCC compiler
- Linux / Unix environment
# Clone the repository
git clone https://github.com/<your-username>/LSB-Steganography.git
cd LSB-Steganography
# Compile
gcc main.c encode.c decode.c -o stego./stego -e <source.bmp> <secret_file> <output_stego.bmp>Example:
./stego -e beautiful.bmp secret.txt stego.bmpOutput:
[INFO] Mode: ENCODING
[INFO] All input files validated. Starting encoding process...
[SUCCESS] Secret file has been encoded into the BMP image successfully!
Output (stego image): stego.bmp
🔓 Decoding — Extract a hidden file from a stego image
./stego -d <stego.bmp> <output_filename>Example:
./stego -d stego.bmp output.txtOutput:
[INFO] Mode: DECODING
[INFO] Input stego image validated. Starting decoding process...
[SUCCESS] Secret file extraction complete!
Output file: output.txt
| ❌ Error | 💬 Message |
|---|---|
| Insufficient image capacity | Error: Image does not have sufficient capacity |
| Invalid BMP file | Error: Invalid argument for encoding/decoding |
| File not found | ERROR: Unable to open file |
| Wrong magic string | Error: Magic string mismatch |
| Concept | Role in Project |
|---|---|
| 🔢 Bitwise Operations | Core LSB embedding and extraction logic |
| 📁 File Handling | Reading BMP and secret files in binary mode |
| 🖼️ BMP Image Format | Understanding pixel layout and header structure |
| 🔏 LSB Technique | Hiding data in the least significant bits of pixel bytes |
| 💻 Command-Line Arguments | Routing encode/decode operations via argc/argv |
| 🧱 Structs | EncodeInfo and DecodeInfo for clean data management |
- Language: C
- Compiler: GCC
- Platform: Linux / Unix
Amar C M 🔧 Embedded Systems Engineer
This project is open-source and available under the MIT License.
💡 "The best hidden message is the one no one knows exists."