Skip to content

AmarCM/LSB--Image-Steganography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕵️ LSB Image Steganography — C Project

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.


🔍 How It Works

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

✨ Features

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

🗂️ Project Structure

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

🚀 Getting Started

🛠️ Prerequisites

  • GCC compiler
  • Linux / Unix environment

🔧 Build

# 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

📖 Usage

🔒 Encoding — Hide a secret file inside a BMP image

./stego -e <source.bmp> <secret_file> <output_stego.bmp>

Example:

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

Output:

[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.txt

Output:

[INFO]    Mode: DECODING
[INFO]    Input stego image validated. Starting decoding process...
[SUCCESS] Secret file extraction complete!
          Output file: output.txt

⚠️ Error Handling

❌ 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

🧠 Concepts Used

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

🛠️ Technologies Used

  • Language: C
  • Compiler: GCC
  • Platform: Linux / Unix

👤 Author

Amar C M 🔧 Embedded Systems Engineer

LinkedIn 📧 amarcm1502@gmail.com


📜 License

This project is open-source and available under the MIT License.


💡 "The best hidden message is the one no one knows exists."

About

LSB Image Steganography in C — hide and extract secret files inside BMP images using Least Significant Bit technique

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages