MCPcopy Index your code
hub / github.com/MearaY/StegaPy

github.com/MearaY/StegaPy @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
221 symbols 775 edges 33 files 163 documented · 74%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

StegaPy: A Python-Based Steganography Tool

Python Version License Code Lines GitHub stars

Language: 中文 | English

StegaPy is a Python-based image steganography and digital watermarking tool. Steganography conceals secret data within an ordinary cover image so that it remains visually indistinguishable from the original; digital watermarking embeds an invisible mark for ownership verification.

This project is a Python rewrite of OpenStego, reproducing its core algorithms while adding a plugin architecture, randomized LSB steganography, a web interface, and a command-line tool.

✨ Features

  • Plugin Architecture: LSB, RandomLSB, and DWT-Dugad are integrated through a unified interface, making it straightforward to add new algorithms
  • Random LSB (RandomLSB): Uses a cryptographic PRNG to randomize bit placement, resisting chi-square statistical steganalysis attacks
  • AES Encryption + Gzip Compression: Supports AES-128/256 payload encryption; adaptive Gzip compression significantly increases effective payload capacity
  • Web Interface: Streamlit-based interactive UI with drag-and-drop upload and before/after image difference visualization
  • Command-Line Interface (CLI): Full coverage of embed, extract, and watermark workflows — suitable for scripting and batch processing
  • Cross-platform: Runs locally via conda or pip, and supports one-click Docker deployment

🚀 Quick Start

Installation

Conda (Recommended)

conda env create -f environment.yml
conda activate StegaPy

pip

pip install -r requirements.txt

Web Interface

streamlit run app.py

Then open http://localhost:8501 in your browser.

web


Command-Line Interface (CLI)

Interactive mode — no arguments; menu-driven with Tab path completion.

python cli.py

cli

Scripting mode — pass arguments directly, suitable for automation.

# Embed data
python cli.py embed -i cover.png -m message.txt -o stego.png
python cli.py embed -i cover.png -m message.txt -o stego.png --algo randlsb -p <password>

cli-embed

# Extract data (--algo must match what was used at embed time)
python cli.py extract -i stego.png -o output/ --algo lsb
python cli.py extract -i stego.png -o output/ --algo randlsb -p <password>

cli-extract

# Watermark: generate signature → embed → verify
python cli.py wm generate-sig -o sig.bin -p <password>
python cli.py wm embed        -i cover.png -s sig.bin -o stego.png -p <password>
python cli.py wm verify       -i stego.png -s sig.bin -p <password>

Full usage: python cli.py --help or python cli.py embed --help


Docker Deployment

docker-compose up -d    # build and start in background
docker-compose ps       # check status
docker-compose down     # stop and remove

The image is built automatically on first run (a few minutes). Then visit http://localhost:8501.

docker-build

CLI inside Docker: the docker-compose setup mounts the project directory into /app.

# Run CLI via the live web container
docker exec stegapy python cli.py embed \
  -i /app/cover.png -m /app/message.txt -o /app/stego.png

# Standalone one-off run (no web container needed)
docker run --rm -v $(pwd):/app stegapy \
  python cli.py embed -i /app/cover.png -m /app/message.txt -o /app/stego.png

Use container-side paths (/app/...). Output files are written back to the mounted directory and immediately accessible on the host.


🧪 Running Tests

End-to-end tests cover both the Python API and CLI:

# Run all tests
pytest tests/test_e2e.py -v

# Run a specific group
pytest tests/test_e2e.py -v -k "LSB"
pytest tests/test_e2e.py -v -k "CLI"

Coverage: LSB / RandomLSB / DWT-Dugad full roundtrips, AES encryption, PSNR image quality assertion, wrong-password exception, all CLI subcommands.

test-results

-k "LSB" filter results:

test-results-lsb

-k "CLI" filter results:

test-results-cli

📁 Project Structure

StegaPy/
├── StegaPy/              # Core package
│   ├── StegaPy.py        # Main dispatcher (compression/encryption/plugin)
│   ├── config.py         # Global configuration
│   ├── plugin_manager.py # Plugin registry
│   ├── plugin/           # Algorithm plugins (LSB, RandomLSB, DWT-Dugad)
│   └── util/             # Utilities (image processing, AES, DWT, etc.)
├── app.py                # Streamlit web application
├── cli.py                # CLI (no args = interactive TUI, with args = scripting mode)
├── tests/                # End-to-end tests (pytest)
├── data/                 # Sample cover image and test text
├── Dockerfile
├── docker-compose.yml
└── requirements.txt

📄 License

This project is licensed under the GNU General Public License v2.0 (GPL-2.0). See LICENSE for details.

🙏 Acknowledgments

This project is a rewrite of OpenStego. Thanks to the original authors: - Samir Vaidya (@syvaidya) - Zelong Zhang (@superzhangzl)

Digital watermarking algorithm based on: Peter Meerwald, Digital Image Watermarking in the Wavelet Transfer Domain, University of Salzburg, 2001.

📧 Contact

Questions or suggestions? Open a GitHub Issue.


This project is intended for educational and lawful purposes only.

Core symbols most depended-on inside this repo

write
called by 33
StegaPy/plugin/lsb/lsb_output_stream.py
read
called by 18
StegaPy/plugin/lsb/lsb_input_stream.py
get_password
called by 17
StegaPy/config.py
byte_array_to_image
called by 14
StegaPy/util/image_util.py
embed_data
called by 12
StegaPy/StegaPy.py
get_max_bits_used_per_channel
called by 12
StegaPy/plugin/lsb/lsb_config.py
get_purposes
called by 11
StegaPy/plugin/base.py
get_data_length
called by 8
StegaPy/plugin/lsb/lsb_data_header.py

Shape

Method 162
Function 34
Class 25

Languages

Python100%

Modules by API surface

tests/test_e2e.py24 symbols
StegaPy/plugin/dwtdugad/dwt_dugad_plugin.py20 symbols
StegaPy/plugin/base.py20 symbols
cli.py16 symbols
StegaPy/plugin/randlsb/random_lsb_plugin.py16 symbols
StegaPy/plugin/lsb/lsb_plugin.py16 symbols
StegaPy/StegaPy.py11 symbols
StegaPy/config.py10 symbols
StegaPy/util/image_util.py9 symbols
StegaPy/plugin/lsb/lsb_data_header.py9 symbols
StegaPy/util/common_util.py6 symbols
StegaPy/plugin/randlsb/random_lsb_output_stream.py6 symbols

For agents

$ claude mcp add StegaPy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact