Skip to content

Repository files navigation

🔐 LSB Image Steganography in C

A command-line application developed in C that securely hides and extracts secret text files inside 24-bit BMP images using the Least Significant Bit (LSB) steganography technique.

Overview

This project demonstrates image steganography by embedding a secret text file into a BMP image without causing any noticeable visual changes. It uses bitwise operations to modify the Least Significant Bit (LSB) of image pixels while preserving the original image quality.

The application supports both encoding (hiding data) and decoding (extracting hidden data) through command-line arguments.


Features

  • Hide a text file inside a 24-bit BMP image
  • Recover the hidden text file from the encoded image
  • Preserves the BMP header to maintain image integrity
  • Uses a magic string to validate encoded images
  • Stores and retrieves:
    • Secret file extension
    • Secret file size
    • Secret file data
  • Checks image capacity before encoding
  • Command-line interface for encoding and decoding
  • Modular implementation using multiple source and header files

🛠 Technologies Used

  • C Programming
  • File Handling (fopen, fread, fwrite, fseek, ftell)
  • Bitwise Operations
  • Structures
  • Command-Line Arguments
  • BMP Image Processing

🔄 Project Workflow

Encoding

Secret.txt
      │
      ▼
Validate Input Files
      │
      ▼
Check Image Capacity
      │
      ▼
Copy BMP Header
      │
      ▼
Encode Magic String
      │
      ▼
Encode File Extension
      │
      ▼
Encode File Size
      │
      ▼
Encode Secret Data
      │
      ▼
Create stego.bmp

Decoding

stego.bmp
      │
      ▼
Verify Magic String
      │
      ▼
Decode Extension
      │
      ▼
Decode File Size
      │
      ▼
Decode Secret Data
      │
      ▼
Recover Secret File

🚀 Compilation

gcc *.c

🔐 Encoding

./a.out -e beautiful.bmp secret.txt stego.bmp

🔓 Decoding

./a.out -d stego.bmp output.txt

Sample Output

Encoding

Read and validate is successful
All files are opened
Checking capacity is successful
BMP Header copied
Magic string encoded
Secret file extension encoded
Secret file size encoded
Secret file data encoded
Encoding successful

Decoding

Magic string validated
Secret file extension decoded
Secret file size decoded
Message decoded successfully

Recovered Message:

My password is SECRET ;)
Courage Is Contagious!

About

A command-line application developed in C that securely hides and extracts secret text files inside 24-bit BMP images using the Least Significant Bit (LSB) steganography technique.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages