Skip to main content

Zero-width-lib is a library for manipulating zero width characters (ZWC), which are non-printing and invisible chars.

Project description

zero-width-lib-python

What's zero-width-lib

Zero-width-lib is a library for manipulating zero width characters (ZWC), which are non-printing and invisible chars.

The common usage of ZWC includes fingerprinting confidential text, embedding hidden text and escaping from string matching (i.e. regex)...

The lib is inspired by this great medium article and got the following features:

  1. 💯stable & cover full test cases
  2. 😆support full width Unicode chars
  3. ⚡️dependencies & performance considered
  4. 📦support CJS, ESM and UMD

Forked from this JavaScript implementation.

WARNING: Not 100% compatible with original implementation.

Install

pip install zero_width_lib

Usage

import zero_width_lib as zwlib
# or
from zero_width_lib import *

# note * represents the invisible ZWC
# U+ represents the Unicode for the character


# 1. convert text
text = "text"
zwc = zwlib.t2z(text)  # '********'
back = zwlib.z2t(zwc)  # 'text'

# 2. embed hidden text
visible = 'hello world'
hidden = 'transplanted by @shacha086'
encoded = zwlib.encode(visible, hidden)  # 'h*********ello world'
decoded = zwlib.decode(encoded)  # 'transplanted by @shacha086'

# 3. extract ZWC from text
extracted = zwlib.extract(encoded)
vis = extracted['visible']  # 'hello world'
hid = extracted['hidden']  # '*********'

# 4. escape from string matching
forbidden = 'forbidden'
escaped = zwlib.split(forbidden)  # 'f*o*r*b*i*d*d*e*n*' 

License

MIT

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

zero_width_lib-1.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

zero_width_lib-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zero_width_lib-1.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.6

File hashes

Hashes for zero_width_lib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d3b1d6e95d43cad02c3d7005107b471d8ef88cdd594ddc85679d4e9e285b48b9
MD5 26d1ff00e647b60a0971fd1846435862
BLAKE2b-256 0530ab8708e448ede52d736386a4cdd54bb21293d971fc345b2c1840e0e6010a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zero_width_lib-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.6

File hashes

Hashes for zero_width_lib-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0da689d252e89364cf5a577e2ebc4aeb93a4ce02a876b8a82a6ab0233dc282ef
MD5 d555c44af567360b0d2ffd422a5549c0
BLAKE2b-256 23bc70fe4d0886a997d26ba495dafb0cbaeacac04d03df837f6212252b14d252

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