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.
- 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
$ ./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.binEncode/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)
Prerequisites:
- Go 1.21 or later
Build:
go build -o bin2img ./cmd/bin2imgUsage:
# 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.
- 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
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/andinternal/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
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
This project is open-source and available under the MIT License.