Neural steganographic data embedding in QR codes with switchable channel modes
Project description
StegaQR
StegaQR embeds a small private payload inside a QR code while preserving the public payload for ordinary QR readers. A trained neural decoder recovers the private data.
The package includes a trained hybrid model, repetition and Hamming error correction, a command line interface, and a Python API. The bundled model carries 100 coded bits. With the default repetition code, it carries up to 4 hidden bytes.
Install
pip install stegaQR
StegaQR supports Python 3.10 through 3.12. PyTorch is installed as a required
dependency. Public QR decoding uses pyzbar. Some Linux and macOS environments also
need the native ZBar library supplied by the operating system.
Command line
Inspect the bundled model:
stegaqr info
Create a QR code with a public URL and a private four byte identifier:
stegaqr encode --public "https://example.com/p" --message "ID42" --out stego.png
Recover both payloads:
stegaqr decode --image stego.png
The generated image includes a quiet zone and nearest neighbor upscaling for reliable
scanning. Use --model PATH to select a different trained checkpoint.
Python API
from stegaqr import decode_hidden, encode_hidden
image = encode_hidden("https://example.com", b"ID42", device="cpu")
public, hidden, metadata = decode_hidden(image, device="cpu")
assert public == "https://example.com"
assert hidden.rstrip(b"\x00") == b"ID42"
CUDA is used when requested and available. Otherwise the package falls back to CPU.
Embedding modes
The research implementation supports three trained architectures:
| Mode | Design | Purpose |
|---|---|---|
| Segregated | One encoder and decoder per color channel | Channel fault isolation |
| Cross-channel | Joint RGB encoder and decoder | Flexible signal placement |
| Hybrid | Joint RGB model with a QR structure mask | Protects finder and control modules |
The bundled model uses the hybrid architecture with a mask-aware spatial bit grid and no color calibration branch.
Reported results
The saved experiment matrix contains five seed comparisons for the three modes, capacity studies from 25 to 200 coded bits, error correction comparisons, an architecture ablation, and a classical baseline. The physical pilot recovered the public and private payloads from all 10 screen to phone photographs after QR detection and perspective rectification.
The robust operating point has a visible color tint. It should be described as robust data embedding, not invisible steganography. The high PSNR operating point is visually subtle but was not validated for physical capture.
See experiments/full/RESULTS.md,
LOGBOOK.md, and paper/main.pdf for the recorded
evidence and limitations.
Development
git clone https://github.com/jemsbhai/stegaQR.git
cd stegaQR
pip install -e ".[dev,analysis]"
pytest
Train and evaluate a checkpoint:
python scripts/train.py --mode hybrid --mask-aware --no-calibration `
--output-dir experiments/run1
python scripts/evaluate.py --checkpoint experiments/run1/best_model.pt
python scripts/evaluate_real.py --checkpoint experiments/run1/best_model.pt
The complete experiment matrix is resumable:
python scripts/run_experiments.py
python scripts/aggregate_results.py
python scripts/generate_figures.py
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stegaqr-0.1.0.tar.gz.
File metadata
- Download URL: stegaqr-0.1.0.tar.gz
- Upload date:
- Size: 2.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb3bb4571898454fd3dce231ee727ed3cabfd6010f0a70c5a8195ee4a1e04b2
|
|
| MD5 |
52c75c3f78561968cd53a4d504340cbd
|
|
| BLAKE2b-256 |
b15c38f8a2c5a561cd006a85ebbc1f5ab50280e928938675474e5fca365c63b5
|
File details
Details for the file stegaqr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stegaqr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
400842c7800dee0f3686ec9af4d0532374d3d89bbc39d940cb941b25c78a419b
|
|
| MD5 |
a7e0451753ae2f6a84180f6a1e7c0320
|
|
| BLAKE2b-256 |
932d77ce7e655148ce90b1375367d196d4ac856a1d035058f30d2164b802f3af
|