Skip to content

FizzyGalacticus/stego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SteGo

Tests codecov

A Go program that hides files inside images using least-significant-bit (LSB) steganography.

Project Structure

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

Usage

stego -i <input_image> [-f <file1> -f <file2> ...] -o <output>

Flags

  • -i Input image file (any Go-supported format: PNG, JPEG, GIF)
  • -f Files or directories to hide (can be specified multiple times)
  • -o Output PNG file (encode mode) or directory (extract mode)

Examples

# 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/

Features

  • 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 -f flag
  • 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

How it works

Encode Mode

  1. Loads the input image (any Go-supported format)
  2. Recursively scans directories specified with -f flags
  3. Creates a tar.gz archive of all files to hide
  4. 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
  5. Saves the result as a PNG file

Extract Mode

  1. Loads the steganographic image
  2. Reads the 4-byte length prefix from LSBs
  3. Extracts the hidden tar.gz archive
  4. Decompresses and extracts all files to the output directory
  5. Preserves original filenames

Limitations

  • 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

About

Hiding files in images... with Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors