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
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
File details
Details for the file canarytrap-1.0.0.tar.gz
.
File metadata
- Download URL: canarytrap-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 152541e8f118e2652af9a275bf447f7c9e18dc3c0016ef1312b8b9828f13b583 |
|
MD5 | 54e8399eb032d277a3b7852ae7c01742 |
|
BLAKE2b-256 | 7136c43eae622f1f8dab7a9d7a71def257745acddc042345e49905073c96d93b |
File details
Details for the file canarytrap-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: canarytrap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71e027cf1dd7bd4e66a1cc2e33b163d777fe025079f6045d4c82eb146e459538 |
|
MD5 | 4c28e11afd71f5934ff63fbec1888cd9 |
|
BLAKE2b-256 | b025450b04acc56a8dcc7fa4981872646066272d334410a891c1559430a89926 |