A C implementation of LSB (Least Significant Bit) Steganography — hides secret files invisibly inside BMP images, and recovers them without any visible change to the image.
Built as part of the Emertxe Advanced C / Embedded Systems training (Skill India / NSDC — QP ELE/Q1501).
Steganography hides the existence of a message (unlike encryption, which hides the content). In this project, secret data is embedded into the least significant bits of BMP pixel bytes — a change invisible to the human eye.
Each pixel byte of a 24-bit BMP image has 8 bits. Only the last bit (LSB) is modified:
Original pixel byte: 1 0 1 1 0 1 1 0
↑ LSB — only this bit changes
After embedding '1': 1 0 1 1 0 1 1 1
1 secret byte requires 8 image bytes (1 bit stored per image byte).
Steganography/
├── main.c → CLI entry point, operation selector
├── encode.c → Full LSB encoding logic
├── encode.h → EncodeInfo struct + function declarations
├── decode.c → Full LSB decoding logic
├── decode.h → DecodeInfo struct + function declarations
├── types.h → typedef: uint, Status, OperationType
├── common.h → MAGIC_STRING "#*" definition
├── beautiful.bmp → Source BMP image (input)
├── secret.txt → Secret file to hide
├── stego.bmp → Output BMP with hidden data (generated)
├── output.txt → Recovered secret file (generated)
├── Makefile → Build automation
└── README.md → Documentation
make./stego -e beautiful.bmp secret.txt stego.bmp
# or
make encode./stego -d stego.bmp output.txt
# or
make decodemake clean[ 54-byte BMP Header (unchanged) ]
[ Magic String "#*" — 2 chars × 8 bytes = 16 bytes ]
[ Extension Size — 32 bytes (4-byte int in LSBs) ]
[ Extension — extn_size chars × 8 bytes ]
[ Secret File Size — 32 bytes (4-byte int in LSBs) ]
[ Secret File Data — file_size chars × 8 bytes ]
[ Remaining image bytes unchanged ]
- Bitwise Operations —
&,|,~,<<,>>to extract and embed individual bits - File Handling —
fopen,fread,fwrite,fseek,ftell,rewind - BMP Header — 54-byte structure; width at offset 18, height at offset 22
- Enums —
Status(e_success/e_failure),OperationType(e_encode/e_decode/e_unsupported) - Structures —
EncodeInfo,DecodeInfofor grouping all operation state - Command-line Arguments —
argc,argv[]for flexible CLI usage - Modular Design — encode.c / decode.c / types.h / common.h / main.c
- Magic String —
#*embedded as a signature to validate stego images
$ ./stego -e beautiful.bmp secret.txt stego.bmp
Selected encoding operation
Validation Successful. Starting encoding...
width = 1024
height = 768
Encoding Completed Successfully
$ ./stego -d stego.bmp output.txt
Selected decoding operation
Validation Successful. Starting decoding...
Magic string verified successfully
File extension: .txt
Secret file size: 12 bytes
Decoding successfull. Data written to output.txt
Decoded file successfully!- Supports only 24-bit BMP images (no PNG, JPG)
- Maximum 100 contacts (compile-time, not a limit here — but image capacity is the constraint)
- Image capacity =
width × height × 3bytes; secret data must fit within this fopenuses"r"/"w"text mode (binary mode"rb"/"wb"would be more robust for BMP)- No password protection on the hidden data
Suchithra S
B.E. Electronics & Communication Engineering — Gopalan College of Engineering & Management (VTU), 2025
Advanced Embedded Systems Training — Emertxe Information Technologies
GitHub: github.com/suchithrasr
LinkedIn: linkedin.com/in/suchithrasr