Skip to main content

Weird text encoder / decoder. Gives reversible, human-readable and lossless encoding.

Project description

PyPI version pipeline status coverage report PyPI pyversion PyPI license PyPI status

DIZZER

Bidirectional human-readable weird-text encoder/decoder.

For each original word in the original text, it leaves the first and last character of it in that position, but shuffles (permutates) all the characters in the middle of the word. If possible, the resulting “encoded” word is different than the original word.

Words shorter than 4 characters or with double letters inside - like: "keep", "seen", "moon" cannot be scrambled - because swapping its characters has no effect.

Key features:

  • simple, straight-forward
  • 100% translatable - back and fourth
  • codec is lossless and doesn't need any additional data for translation
  • scrambles all numbers and slugs as well
  • keeps other non-word text parts unchanged

Scrambling order is pseudo-random and different for each word.

Usage

import dizzer

original_text = """
Text can contain unlimited number of whitespaces, newlines etc.
Numbers like 12345, 1234567, 987654321 or 123456789 are also scrambled.
"""
encoded = dizzer.encode(original_text)

print(encoded)

# Txet can cnitaon umnitelid nmeubr of wtsehaecips, newniels etc.
# Numbres lkie 14325, 1346257, 967843251 or 143267859 are aslo scrmeabld.

# reverse operation:
decoded = dizzer.decode(encoded)

print(decoded)

# Text can contain unlimited number of whitespaces, newlines etc.
# Numbers like 12345, 1234567, 987654321 or 123456789 are also scrambled. 

Installation

pip install dizzer

It has no dependencies and works in python 3.7, 3.8, 3.9 and pypy3.

Interoperability check

There is non-zero probability, that the algorithm works different on sophisticated environments (i.e. when your python interpreter uses weird pseudo-random generator library).

At import time of dizzer package there is a self-check statement. It checks if this algorithm works in your environment. There is a snippet that raises an import error if a malfunction is detected. In other words - if you are able to import dizzer - you can be sure, that your encoded text can be decoded on othr machines.

The self-check statement

import dizzer


PROPER_TEXT = """
This sentence approves that dizzer can be used on your machine.
If this assertion is not raised - it means you can read and write messages
that are fully translatable on other machines.
"""

EXPECTED_ENCODING = """
Tihs senectne aepvorps taht dzzier can be uesd on yuor mhcaine.
If tihs aosirtsen is not risaed - it mneas you can raed and wtrie msesgeas
taht are fluly tbnslalatrae on oethr mhacneis.
"""

local_encoding = dizzer.encode(PROPER_TEXT)
back = dizzer.decode(local_encoding)

assert local_encoding == EXPECTED_ENCODING, "Failed to encode."
assert back == PROPER_TEXT, "Failed to decode."

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

dizzer-0.1.2.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

dizzer-0.1.2-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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