Skip to main content

A Python package to watermark text.

Project description

CanaryTrap

CanaryTrap is a Python package that uses the concept of a "canary trap" to watermark text using unicode spaces. By converting regular spaces to unicode spaces according to a binary pattern, you can add a hidden signature to your text.

Installation

You can install CanaryTrap using pip:

pip install canarytrap

How to use

First, import the package:

import canarytrap as canary

To watermark your text, use the unicode_space_encode function. You can either provide a binary string or let the function generate a random one:

text = "Hello world this is a test"
watermarked_text, binary_str = canary.unicode_space_encode(text)
print(watermarked_text)  # Watermarked text
print(binary_str)  # Binary string used for watermarking

You can convert the watermarked text back to binary using the unicode_space_to_binary_str function:

binary_str_back = canary.unicode_space_to_binary_str(watermarked_text)
print(binary_str_back)  # Should be the same as binary_str

To check if a text matches a given binary string, use the unicode_space_match function:

match = canary.unicode_space_match(watermarked_text, binary_str)
print(match)  # Should be 1.0 if text is not modified

This package is very useful for checking the integrity of text, finding leaks, or tracing the origin of text documents.

Note

The watermark is invisible but can be removed or altered if the text is converted to plain text or the spaces are normalized. Use this package with awareness of its limitations.

Also, if the watermarked text is edited (spaces are added, removed, or replaced), the match percentage returned by the unicode_space_match function may be less than 1.0. If you get a match percentage of less than 1.0, it means that the text was likely edited after being watermarked. The match percentage gives an estimate of how much of the original watermark remains in the text.

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

canarytrap-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

canarytrap-1.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file canarytrap-1.0.1.tar.gz.

File metadata

  • Download URL: canarytrap-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for canarytrap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 10ebd2f4509b0f40af4cbcea51258c39f7513f1f8f06c1cc8c4253470b234b30
MD5 86dba17c9e92ce08f97177400bc67dc9
BLAKE2b-256 07339a6e7ad9b76f8c050d45bd07f16abd18345e9eb8e0d3fbb1f52361ce0746

See more details on using hashes here.

File details

Details for the file canarytrap-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: canarytrap-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for canarytrap-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9299e9d7973316adaa4de3941a39e09d9e08269d88173f6bb002c3f8dd997bd1
MD5 cf0eb6e305ebd838f7899c20b0c2a56b
BLAKE2b-256 45de6a0c71dc037c8bf2240dc5d1cdb321304c859982818284dfa7c175909666

See more details on using hashes here.

Supported by

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