Skip to content

High-performance Go tool for lossless binary-to-image conversion and LSB steganography. Convert executables/archives to PNG images or embed data invisibly in existing images with perfect byte-for-byte reconstruction.

Notifications You must be signed in to change notification settings

harispdev/bin2img

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary to Bitmap Converter & Steganography Tool

License: MIT Go Version

A high-performance Go application that converts binary files (executables, archives, etc.) into bitmap images and can perfectly reconstruct the original files. Features advanced LSB steganography capabilities to embed binary data into existing images without any visible changes to the image appearance.


📌 Features:

  • Direct Binary-to-Image Conversion: Maps binary data directly to RGB pixels with lossless encoding
  • LSB Steganography: Embed binary files into existing images using least significant bit encoding
  • Perfect Reconstruction: 100% data integrity - original files are reconstructed byte-for-byte
  • Visual Preservation: Steganography maintains original image appearance (imperceptible changes)
  • Automatic Organization: All output files organized in dedicated output/ directory
  • Flexible Output Paths: Support for custom filenames and subdirectories
  • Clean Architecture: Well-organized codebase following Go best practices

📷 Example Output:

$ ./bin2img encode myapp.exe output.png
Successfully encoded myapp.exe to output/output.png

$ ./bin2img decode output/output.png myapp_restored.exe
Successfully decoded output/output.png to output/myapp_restored.exe

$ diff myapp.exe output/myapp_restored.exe
# Files are identical - perfect reconstruction! ✓

$ ./bin2img embed secret.bin target-image.png stego.png
Successfully embedded secret.bin into target-image.png (saved as output/stego.png)

$ ./bin2img extract output/stego.png extracted.bin
Successfully extracted data from output/stego.png to output/extracted.bin

⚙️ How It Works

Encode/Decode Mode:

  • Maps each byte of binary data to RGB pixel channels (3 bytes per pixel)
  • Stores file size metadata in the first 4 pixels
  • Calculates optimal image dimensions to fit all data efficiently
  • Uses PNG format for lossless compression

Embed/Extract Mode (Steganography):

  • Uses LSB (Least Significant Bit) steganography technique
  • Each bit of binary data is stored in the LSB of RGB channels
  • Only modifies the least significant bit (±1 color value change)
  • Visually imperceptible - images look identical to originals
  • Capacity: (width × height × 3) / 8 - 8 bytes (8 bytes reserved for metadata)

🚀 Building and Running

Prerequisites:

  • Go 1.21 or later

Build:

go build -o bin2img ./cmd/bin2img

Usage:

# Encode binary to image
./bin2img encode <input_file> [output_image.png]

# Decode image to binary
./bin2img decode <input_image.png> [output_file]

# Embed binary into existing image (steganography)
./bin2img embed <input_file> <target_image.png> [output_image.png]

# Extract embedded data from image
./bin2img extract <input_image.png> [output_file]

💡 All output files are automatically saved to the output/ directory. Custom paths with subdirectories are supported.


⚡ Performance Notes

  • Lossless Encoding: PNG format ensures perfect data reconstruction
  • Efficient Storage: Direct pixel mapping provides optimal space utilization
  • Steganography Capacity: Each pixel stores 3 bits, allowing substantial data embedding
  • Image Compatibility: Works with any PNG image format (RGBA, NRGBA, etc.)
  • Memory Efficient: Processes images pixel-by-pixel without loading entire images into memory unnecessarily

🤔 Why This Project Matters

This project demonstrates:

  • Advanced Image Processing: Direct manipulation of pixel data with format conversion
  • Cryptographic Techniques: Implementation of LSB steganography for data hiding
  • Data Integrity: Perfect round-trip conversion with byte-for-byte accuracy
  • Clean Architecture: Well-organized codebase with proper separation of concerns
  • Go Best Practices: Following standard project layout with cmd/ and internal/ directories

It is ideal for showcasing:

  • Image processing and manipulation skills
  • Steganography and data hiding techniques
  • Binary data handling and encoding
  • Modern Go software architecture
  • Practical applications of bit manipulation

📁 Project Structure

go-code-to-image/
├── cmd/
│   └── bin2img/          # CLI application entry point
├── internal/
│   ├── encoder/          # Binary ↔ Bitmap conversion
│   ├── steganography/    # LSB embedding/extraction
│   ├── imageutil/        # Image format utilities
│   └── utils/            # Helper functions
└── output/               # Default output directory

📄 License

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

About

High-performance Go tool for lossless binary-to-image conversion and LSB steganography. Convert executables/archives to PNG images or embed data invisibly in existing images with perfect byte-for-byte reconstruction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages