Skip to main content

Encrypted Image Watermark Injector / Validator

Project description

Pixseal

Encrypted image watermark injector/validator that hides text (optionally RSA encrypted) inside 24-bit PNG or BMP files by modulating the parity of carefully selected color channels.

Features

  • Noise-resistant embedding: Chooses the RGB component whose value is farthest from 127 and nudges it ±1 to match each payload bit, keeping noise visually imperceptible.
  • Sentinel-based framing: Automatically prefixes/suffixes payloads with START-VALIDATION / END-VALIDATION markers so the validator knows where to look.
  • Optional RSA envelope: When you pass a public key, both the sentinels and payload are encrypted with OAEP (SHA-256). Validation decrypts with the matching private key before building a verdict.
  • Pure Python image I/O: SimpleImage reads/writes uncompressed BMPs as well as 8-bit RGB/RGBA PNGs without third-party imaging libraries.

Installation

pip install Pixseal
# or for local development
pip install -e ./pip_package

Python 3.8+ is required. The only runtime dependency is cryptography>=41.0.0.

Usage

Sign an image

from Pixseal import signImage

result = signImage(
    imagePath="original.png",
    hiddenString="!Validation:kyj9447@mailmail.com",
    publicKeyPath="SSL/public_key.pem",  # omit for plain-text embedding
)
result.save("signed_original.png")
  • The payload is looped if it runs out before the image ends, so even small files carry the full sentinel/payload/end pattern.
  • When publicKeyPath is omitted, the payload remains plain text.

Validate and (optionally) decrypt

from Pixseal import validateImage

report = validateImage(
    imagePath="signed_original.png",
    privKeyPath="SSL/private_key.pem",  # omit for plain-text payloads
)

print(report["extractedString"])
print(report["validationReport"])

validateImage returns:

{
    "extractedString": "<payload or encrypted blob>",
    "validationReport": {
        "arrayLength": 4,
        "lengthCheck": True,
        "startCheck": True,
        "endCheck": True,
        "isDecrypted": True,
        "verdict": True,
        # decryptSkipMessage when a decrypt request was skipped
    }
}

CLI demo script

python testRun.py offers an interactive flow:

  1. Choose 1 to sign an image. It reads original.png, asks for a payload (default !Validation:kyj9447@mailmail.com), optionally encrypts with SSL/public_key.pem, and writes signed_<name>.png.
  2. Choose 2 to validate. It reads signed_original.png, optionally decrypts with SSL/private_key.pem, and prints both the extracted string and verdict.

Key management

Generate a test RSA pair (PKCS#8) with OpenSSL:

openssl genpkey -algorithm RSA -out SSL/private_key.pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in SSL/private_key.pem -out SSL/public_key.pem

Point publicKeyPath / privKeyPath to these files.

API reference

Function Description
signImage(imagePath, hiddenString, publicKeyPath=None) Loads a PNG/BMP, injects hiddenString plus sentinels, encrypting each chunk when publicKeyPath is provided. Returns a SimpleImage that you can save() or saveBmp().
validateImage(imagePath, privKeyPath=None) Reads the hidden bit stream back, splits by newlines, deduplicates, optionally decrypts each chunk (Base64 indicates ciphertext), and returns the payload plus a validation report.
SimpleImage.open(path) Low-level helper that exposes size, getPixel, putPixel, save, and saveBmp. Useful if you need custom preprocessing before/after signing.
BinaryProvider, addHiddenBit, readHiddenBit, buildValidationReport Lower-level primitives exported from Pixseal for advanced workflows or experimentation.

Examples

Original Signed (!Validation:kyj9447@mailmail.com)

Validation output excerpt:

START-VALIDATION
!Validation:kyj9447@mailmail.com
undecrypted partial String
END-VALIDATION

(When encrypted, each line appears as Base64 until decrypted with the RSA private key.)

Related projects

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

pixseal-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

pixseal-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pixseal-0.1.1.tar.gz.

File metadata

  • Download URL: pixseal-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pixseal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 87c9151272d28b9bf571e68273fb276d62f01cf7143b17c8097b25f9a7a71a66
MD5 863968517ad2ae62989c5468be5edfba
BLAKE2b-256 88ecfdc5ffd4660bd57a848b5e2009b53b3cc7ce1e65a57dc28ff5edcdcf65b7

See more details on using hashes here.

File details

Details for the file pixseal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pixseal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pixseal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cdc755f6724763c37156afa640ae5df6d9c742d705cad7760c65f6d5594548b
MD5 05087061b82e08957b701b561459d07f
BLAKE2b-256 b8c6958d0103619c1d69864f180ebe686b7beeddccae9fcc6e3e3ebe402357f5

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