Skip to main content

stegosphere logo

Stegosphere

Stegosphere is a versatile library for both applying steganography (hiding data within media) and performing steganalysis (detecting hidden data). It provides a flexible framework for any data representable as a NumPy array, including images, videos, audios and TrueType fonts. Furthermore, multi-file embedding, Hamming codes, payload compression, encryption and visualization are available, as well as a research toolbox for evaluating method performance and security.

Documentation

Online documentation is available at https://maximilian-koch.github.io/stegosphere/

Detailed examples are available at https://github.com/Maximilian-Koch/stegosphere/tree/main/examples

Installation

The latest release (and required dependencies) can be installed from PyPI: pip install stegosphere

To install all optional dependencies for various additional operations, use: pip install stegosphere[complete]

The only requirements are numpy and lazy-loader. The file containers work with PIL/Pillow for images, fontTools for TTF files, cv2 for videos, and soundfile for audios. Using files containers is not required as they only provide the binding between files and numpy arrays.

Examples

Extracting a payload

The following example reads a hidden payload from the library's logo:

from stegosphere.embeddings import LSB
from stegosphere import image
from stegosphere import binary_to_data

img = image.ImageContainer('logo_small_stego.png')
px = img.read()
payload = LSB.extract(px)

print(binary_to_data(payload).decode())

Embedding and extracting

The following example hides and reads a payload from an audio file using echo hiding steganography:

from stegosphere.embeddings import echo_hiding
from stegosphere import audio

aud = audio.AudioContainer('audio.wav')
frames = aud.read()
payload = '01110100011001010111001101110100'
stego_frames = echo_hiding.embed(frames,payload,alpha=0.4)
#aud.save('stego_audio.wav', stego_frames)

dec_payload = echo_hiding.extract(stego_frames,n_bits=len(payload),alpha=0.4)
print(dec_payload)
print(payload)
#minimal differences are possible due to imperfect delay detection!

Advanced functionalities

The following example uses (Pixel) Value Differencing to hide a payload within an image. The payload uses Hamming 7-4 error correcting codes and is embedded randomly across the image with a seed. PSNR is measured and a Gaussian noise attack is being simulated. The image is saved, loaded, the bit-error-rate is measured, and differences are visualized. (Note: Storing and saving into a file is not needed for analysis. This is purely for demonstration.)

import stegosphere
from stegosphere.embeddings import VD
from stegosphere import image
from stegosphere.costs import HILL
from stegosphere.selector import greedy_indices
from stegosphere.tools import ecc
from stegosphere.analysis import imperceptibility, robustness, accuracy, visualizer

img = image.ImageContainer('logo_small.png')
px = img.read()
payload = "payload!"*300

#convert to binary so that ECC can be applied
bin_payload = stegosphere.data_to_binary(payload)
ecc_payload = ecc.Hamming7_4.encode(bin_payload)
#do payload framing / end-of-payload manually
stego_px = VD.embed(px, ecc_payload, framing=None, seed=0)

psnr = imperceptibility.psnr(px, stego_px)
#simulating attack with very low sigma
stego_px = robustness.gaussian_noise_attack(stego_px,sigma=0.1)

print(f"PSNR: {psnr:.2f}dB")
img.save('stego_image.png',stego_px)

stego_img = image.ImageContainer('stego_image.png')
stego_px = img.read()
output = VD.extract(stego_px, framing=None, seed=0)
decc_payload = ecc.Hamming7_4.decode(output[:len(ecc_payload)])
ber = accuracy.bit_error_rate(decc_payload, bin_payload)
print(f"Bit error rate: {ber:.2f}%") #should be 0%
#Due to the seed, the differences are randomly distributed.
visualizer.difference_heatmap(px,stego_px)

Contributing

Any support or input is always welcomed. Additional embedding and cost functions are very much needed.

Contact:

Email: maximilian.koch@student.uva.nl

LinkedIn: https://www.linkedin.com/in/maximilian-jw-koch/

Metadata

Release files for stegosphere 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stegosphere 1.3
File Size Uploaded
stegosphere-1.3.tar.gz 147.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stegosphere 1.3
File Interpreter ABI Platform
stegosphere-1.3-py3-none-any.whl Python 3 none any Details

Total release size: 289.9 kB

Release files / stegosphere-1.3.tar.gz

Download URL stegosphere-1.3.tar.gz
Size 147.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c82dbc11701547d711c0e2c8cf9a8608e98df784f52a7ec8cbf781c05ffcfd59
BLAKE2b-256 checksum
How to use checksums
b8c1d8ce002f7deefc1564453347c0a28f0113ee4a395b34d0370abb06b7df71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / stegosphere-1.3-py3-none-any.whl

Download URL stegosphere-1.3-py3-none-any.whl
Size 142.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea5c1ae661f659a76ebe3472da69caf586052bb3f79429989bbb21fec2d21b24
BLAKE2b-256 checksum
How to use checksums
981a8e7582b64616a28108f87f46901acd24191a43038b00aa3a6cc4865d3b68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page