Skip to main content

Fast and efficient coding of binary data into non-breaking unicode whitespace

Project description

invisicode

Encodes arbitrary byte-strings into strings that display invisibly on devices and platforms supporting unicode.

Operates in base 4096 with one additional padding character for specific input widths, meaning 1.5 bytes per character on average.

Originally a coding scheme designed for github.com/thomas-xin/Miza, as one of the methods to hide small amounts of persistent data in text messages to reduce visual clutter.

Usage

encode(
    b: str | bytes | bytearray | memoryview | numpy.ndarray,
    padding: int = 119162
) -> str
decode(s: str, padding: int = 119162) -> bytes
import invisicode
data = b"Hello World!"
encoded = invisicode.encode(data) # '\U000e0548\U000e06c6\U000e0f6c\U000e0206\U000e0f57\U000e0726\U000e046c\U000e0216'
assert invisicode.decode(encoded) == data # b"Hello World!"
import invisicode
data = "Hello World! ❤️"
encoded = invisicode.encode(data) # '\U000e0548\U000e06c6\U000e0f6c\U000e0206\U000e0f57\U000e0726\U000e046c\U000e0216\U000e0220\U000e09de\U000e0fa4\U000e0b8e\U000e008f'
assert invisicode.decode(encoded) == data.encode("utf-8") # b'Hello World! \xe2\x9d\xa4\xef\xb8\x8f'
import invisicode
import numpy as np
data = np.random.randint(0, 256, size=10 ** 8, dtype=np.uint8)
encoded = invisicode.encode(data) # '\U000e05b7\U000e0504\U000e02cc\U000e09a9\U000e0df5\U000e0066\U000e0d96󠅋\U000e0959\U000e0469...
assert invisicode.decode(encoded) == data.tobytes()

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

invisicode-1.0.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

invisicode-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: invisicode-1.0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.8

File hashes

Hashes for invisicode-1.0.1.tar.gz
Algorithm Hash digest
SHA256 22ef9e50b2cd6bd6799a086b8c98cbbb05ce59e0894469f58266a8d0cfbc6644
MD5 f7d38249aba6aa54ca65846f1f25cb14
BLAKE2b-256 2a856ce407b9feded0133a5a43dc6ae75f2709b31c94d0e1a3839ef5599d76a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: invisicode-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.8

File hashes

Hashes for invisicode-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26f7ba675c102357ba38c981a7a434741eedeabcd40e37df571ff4875e90df94
MD5 134d1a2b3bfca2c57d6c34e4dbd6fd15
BLAKE2b-256 57027a6e304ee754bc03b3557950008337875f3467d43a81ec2235c53df96349

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