Skip to main content

A Python interface for Syndrome Trellis Codes Steganography

Project description

pySTC

pySTC is a Python interface for Syndrome-Trellis Codes (STC), a method used in steganography to minimize embedding distortion when hiding information within digital media. STCs are linear convolutional codes represented by a parity-check matrix, allowing efficient embedding while preserving the quality of the cover medium.

This library is based on the C++ implementation of Syndrome-Trellis Codes available at Binghamton University's STC repository. We extend our gratitude to the original authors for their contribution to the field of steganography.

Installation

To install pySTC, you can use the precompiled binaries available in the dist directory. This ensures compatibility and simplifies the installation process. Run the following command:

pip install dist/pySTC-*.whl

Replace * with the appropriate version of the wheel file.

Usage

Below is an example of how to use pySTC for embedding and extracting messages using Syndrome-Trellis Codes. In this example, we have performed the cost calculation using HILL as defined in the paper A New Cost Function for Spatial Image Steganography by Bin Li, Ming Wang, Jiwu Huang and Xiaolong Li.

import pystc
import numpy as np
import imageio.v3 as iio
import warnings
from scipy import signal

warnings.filterwarnings('ignore', category=RuntimeWarning)

input_image = 'image.pgm'

def HILL(I):
    H = np.array(
       [[-1,  2, -1],
        [ 2, -4,  2],
        [-1,  2, -1]])
    L1 = np.ones((3, 3)).astype('float32')/(3**2)
    L2 = np.ones((15, 15)).astype('float32')/(15**2)
    costs = signal.convolve2d(I, H, mode='same')  
    costs = abs(costs)
    costs = signal.convolve2d(costs, L1, mode='same')  
    costs = 1/costs
    costs = signal.convolve2d(costs, L2, mode='same')  
    costs[costs == np.inf] = 1
    return costs

I = iio.imread(input_image)

costs = HILL(I)
seed = 32 # secret seed

message = "Hello World".encode()
stego = pystc.hide(message, I, costs, costs, seed, mx=255, mn=0)

message_extracted = pystc.unhide(stego, seed)
print("Extracted:", message_extracted.decode())

Acknowledgments

Part of the C/C++ code used by HStego comes from the Digital Data Embedding Laboratory. We sincerely appreciate their work in developing and sharing this technology.

These methods are described in the following papers:

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystcstego-0.1.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pystcstego-0.1.0-cp312-cp312-manylinux2014_x86_64.whl (176.9 kB view details)

Uploaded CPython 3.12

pystcstego-0.1.0-cp311-cp311-win_amd64.whl (30.1 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file pystcstego-0.1.0.tar.gz.

File metadata

  • Download URL: pystcstego-0.1.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pystcstego-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc3e4750cae53cc55d90516ccc1f96e77d81a24d0fe1c64629e3cc36896ecd54
MD5 54f0fa292d8c5d4e6c410cb3fba5bd22
BLAKE2b-256 d6d1746372eaba1a3a1e61bb18bd174720c140ac2599b4b1bd2373b92f7bb014

See more details on using hashes here.

File details

Details for the file pystcstego-0.1.0-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pystcstego-0.1.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 099e69cc2310a532af945baed4a3baaef88f3f4430184b6f1dffa15f9ceb063c
MD5 0425f748feb07824f74cbe748d786a7b
BLAKE2b-256 0da75e9f8fa16b29d951b9869c060b15ebf3d6118b080e750b0d74d333aee0b5

See more details on using hashes here.

File details

Details for the file pystcstego-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pystcstego-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pystcstego-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4a894d59b690da60fcf782b698257850fbd7afb436b5753470bbe643144ae2ac
MD5 5d7820a3111677bf27dbb9f9b0b8b4b2
BLAKE2b-256 0218962e4d951cc0a5506465bfaa434c5eaf6dc99e554f6049ce5aedc2df627f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page