wc32 custom encoding library
Project description
wc32
A custom Python encoding library with optional salt support for non-deterministic output.
Installation
pip install wc32
Usage
Basic Encoding/Decoding
from wc32 import encode, decode
# Encode with a key (deterministic - same input always produces same output)
encoded = encode("Hello, World!", "my_secret_key")
print(encoded) # e.g., "kR.TV.rx.r-.yU.mD.Hj"
# Decode with the same key
decoded = decode(encoded, "my_secret_key")
print(decoded) # "Hello, World!"
Non-Deterministic Encoding (Recommended)
By default, encoding is deterministic (same text + key = same output). For security, you can enable random salt:
# With random salt (recommended for sensitive data)
encoded = encode("Hello", "key", salt=True)
# Each call produces different output:
# "a1b2c3d4.e5f6.g7h8.i9j0.k1l2" (first call)
# "f5e6d7c8.9a0b.1c2d.3e4f.5g6h" (second call)
# Decode works automatically (salt is embedded in encoded string)
decoded = decode(encoded, "key") # "Hello"
Custom Salt
You can provide your own salt for reproducible non-deterministic output:
# Custom salt (must be 8-32 hex characters)
encoded = encode("Hello", "key", salt="deadbeef12345678")
decoded = decode(encoded, "key") # "Hello"
API Reference
encode(text: str, key: str, salt: Union[bool, str] = False) -> str
Encodes text using a custom base encoding with optional salt.
- text: The string to encode
- key: Secret key for encoding
- salt:
False(default): Deterministic encodingTrue: Generate random saltstr: Use custom hex salt (8-32 characters)
decode(encoded_text: str, key: str) -> str
Decodes previously encoded text.
- encoded_text: The encoded string
- key: Must match the key used for encoding
Error Handling
The library raises descriptive errors for invalid inputs:
from wc32 import encode, decode
# Empty key
encode("text", "") # ValueError: Key must not be empty
# Wrong key (produces garbage, not an error)
decode(encoded, "wrong_key") # Returns garbled text
# Invalid characters
decode("invalid!!!", "key") # ValueError: Invalid character
Security Notes
- This is not encryption. It provides obfuscation only.
- Without salt, output is deterministic - don't use for sensitive data without salt.
- With
salt=True, same text produces different outputs (semantically secure). - For proper security, use established encryption libraries like
cryptography.
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 Distribution
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 wc32-1.0.0.tar.gz.
File metadata
- Download URL: wc32-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6190167444b01f1d9823ced8db3df5fcf8a6a3350d6c38e23e04d356cfe5f61a
|
|
| MD5 |
5dd7490e4c3072c5edd3c12825cd690f
|
|
| BLAKE2b-256 |
cab5f76b925a20ac7e5d198968876a5307defa5680205021bcb05da7451f44d7
|
File details
Details for the file wc32-1.0.0-py3-none-any.whl.
File metadata
- Download URL: wc32-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e181768800272c7ab2b7797a6e2ccc8e2e9006f78a75798220627a02a5e43864
|
|
| MD5 |
5c9a1adb42fd1419cbaea4a59160d394
|
|
| BLAKE2b-256 |
984eec8622300f84ed94b38789f67ce3939052f04c07fc828c63453e9a9f2c62
|