A Go program that hides files inside images using least-significant-bit (LSB) steganography.
stego/
├── main.go # CLI application
├── stego/ # Reusable steganography package
│ ├── stego.go # LSB encode/decode functions
│ ├── archive.go # Tar.gz archive operations
│ └── README.md # Package documentation
├── test/ # Test files and test data (git-ignored)
├── go.mod
├── .gitignore
└── README.md
stego -i <input_image> [-f <file1> -f <file2> ...] -o <output>-iInput image file (any Go-supported format: PNG, JPEG, GIF)-fFiles or directories to hide (can be specified multiple times)-oOutput PNG file (encode mode) or directory (extract mode)
# Build the executable
go build -o stego
# Encode: Hide files in an image
./stego -i input.jpg -f secret1.txt -f secret2.dat -o output.png
# Encode: Hide multiple files
./stego -i photo.png -f file1.txt -f file2.pdf -f file3.zip -o encoded.png
# Encode: Hide entire directory
./stego -i photo.jpg -f my_secret_folder -o encoded.png
# Extract: Extract hidden files from image
./stego -i encoded.png -o extracted_files/- Dual Mode Operation: Encode files into images or extract them back
- Directory Structure Preservation: Maintains full directory hierarchy during encode/extract
- Supports all image formats that Go natively supports (JPEG, PNG, GIF)
- Recursive directory processing with
-fflag - Creates an in-memory tar.gz archive of multiple files
- Uses LSB steganography to hide data in the least significant bits of RGB channels
- Outputs result as PNG format
- Includes data length prefix for reliable extraction
- Loads the input image (any Go-supported format)
- Recursively scans directories specified with
-fflags - Creates a tar.gz archive of all files to hide
- Embeds the archive into the image using LSB steganography:
- Stores data length as 4-byte prefix
- Modifies the least significant bit of each RGB color channel
- Invisible to the human eye
- Saves the result as a PNG file
- Loads the steganographic image
- Reads the 4-byte length prefix from LSBs
- Extracts the hidden tar.gz archive
- Decompresses and extracts all files to the output directory
- Preserves original filenames
- Image must be large enough to hold the data (3 bits per pixel)
- Required bits = (total file size + 4 bytes) × 8
- PNG output may be larger than original compressed formats