Skip to main content

Embedded messages in text for Python.

Project description

This library includes a set of tools for using zero-width unicode characters to embed human-invisible messages in text.

Watermarking

You can use invisible ink to uniquely identify a piece of text by embedding a UUID:

>>> from invisible_ink import encode_watermark, decode_watermark
>>> encoded_text, uuid = encode_watermark(u'asdf')
>>> print encoded_text
asdf
>>> uuid
UUID('3ca37a37-9c5a-4b9e-a9c0-a50c47c48dba')
>>> decode_watermark(encoded_text)
(u'asdf', UUID('3ca37a37-9c5a-4b9e-a9c0-a50c47c48dba'))

encode_watermark (text, watermark_uuid=None, prepend=False)

Encodes the given text with a watermark string generated from the given uuid. Optionally appends or prepends the watermark string.

Parameters:

  • text: Unicode string to which the watermark will be added

  • watermark_uuid: uuid.UUID instance to use as the watermark. (uuid.uuid4() will be used to generate one if not provided.)

  • prepend: Indicates whether the watermark should be prended to text (defaults to False). If False, the watermark will be appended.

Returns:

A 2-tuple: (encoded_text, watermark_uuid)

decode_watermark (encoded_text)

Decodes the given text, separating out the original text and the watermark uuid.

Paramters:

  • encoded_text: Unicode string which potentially includes a watermark

Returns:

A 2-tuple: (text, watermark_uuid). If no watermark is detected, text is the original text and watermark_uuid is None.

Installation

$ pip install invisible-ink

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

invisible-ink-0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

invisible_ink-0.1-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file invisible-ink-0.1.tar.gz.

File metadata

  • Download URL: invisible-ink-0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for invisible-ink-0.1.tar.gz
Algorithm Hash digest
SHA256 31d706ad2eccc04ca4ea7969782d20c13120ac2ed257910de5da7f9a44888c62
MD5 5b2aaa17bf0220ff7d641d368e084614
BLAKE2b-256 5822b592694594cce2f0a13c5cdf8e1d55815edaf3f9114148af7e7ee446a04b

See more details on using hashes here.

File details

Details for the file invisible_ink-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for invisible_ink-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e515b65e4d9b017f20ee6277ff951ac35448f5344e9885c3c3340d263803fdf2
MD5 86b3744cf58a124172d51b4d841db429
BLAKE2b-256 92a177233c9d48c39b6b84645bb54a0dc5317d0cf15c1b0f293b35e25235b5b1

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