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:
- 💯stable & cover full test cases
- 😆support full width Unicode chars
- ⚡️dependencies & performance considered
- 📦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
# 0. six different zwc
my_dict = zwlib.zeroWidthDict
print(my_dict.zeroWidthSpace) # '*' U+200B
print(my_dict.zeroWidthNonJoiner) # '*' U+200C
print(my_dict.zeroWidthJoiner) # '*' U+200D
print(my_dict.leftToRightMark) # '*' U+200E
print(my_dict.rightToLeftMark) # '*' U+200F
print(my_dict.zeroWidthNoBreakSpace) # '*' U+FEFF
# 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.vis # 'hello world'
hid = extracted.hid # '*********'
# 4. escape from string matching
forbidden = 'forbidden'
escaped = zwlib.split(forbidden) # 'f*o*r*b*i*d*d*e*n*'
License
MIT
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zero_width_lib-1.0.0-py3-none-any.whl.
File metadata
- Download URL: zero_width_lib-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13bb6c1d352b28844c9df739d5cf81301eec76c9f4fe44f9dccb11397529a4c5
|
|
| MD5 |
93676daa9f34ad725ad5bc7e64d69eb3
|
|
| BLAKE2b-256 |
228739688a826ed61c5c3040e07243ce1a029ab0b4b63438af5f9982d16c2375
|