Text Encoder & Decoder — Python library with optional salt support.
pip install wc32
from wc32 import encode, decode
encoded = encode("Hello, World!", "my_secret_key")
decoded = decode(encoded, "my_secret_key")
print(decoded) # Hello, World!
encoded = encode("Hello", "key", salt=True)
# Each call produces different output
decoded = decode(encoded, "key") # Hello
encoded = encode("Hello", "key", salt="deadbeef12345678")
decoded = decode(encoded, "key") # Hello
A salt is a random value mixed into the encoding process before your key is applied. It has nothing to do with making output "more secret" — its sole job is to make the same input produce a different output every time.
Encoding "hello" with key "mykey" will always produce the exact same string.
If someone sees two identical encoded values they immediately know the original inputs were identical too.
That leaks information — even without breaking the encoding.
encode("hello", "mykey") # → always "Th.T7.T-.T*.TD"
encode("hello", "mykey") # → always "Th.T7.T-.T*.TD" ← identical, information leaked
A random 8-character hex prefix is generated and folded into the keystream before encoding.
Every call produces a completely different string even for identical inputs.
The salt is stored at the start of the encoded output so decode() can recover it automatically —
you never have to pass the salt separately.
encode("hello", "mykey", salt=True) # → "a3f9c1b2.Xk.mR.pQ.nT.wZ"
encode("hello", "mykey", salt=True) # → "e7d20a5f.Yj.oS.qL.vU.xN" ← different every time
decode("a3f9c1b2.Xk.mR.pQ.nT.wZ", "mykey") # → "hello" ✓
decode("e7d20a5f.Yj.oS.qL.vU.xN", "mykey") # → "hello" ✓
Use salt=True whenever the same value might be encoded more than once and you don't
want observers to correlate the outputs — e.g. storing tokens, session identifiers, or any repeated string.
Skip it only when you intentionally need reproducible output (caching, deduplication).
You can pass your own 8–32 character hex string as the salt. This is useful for deterministic but key-varied encoding — two parties can agree on a salt in advance and both produce identical output.
encode("hello", "mykey", salt="deadbeef")
decode("deadbeef.Xk.mR.pQ.nT.wZ", "mykey") # → "hello"
cryptography.
| Param | Description |
|---|---|
text | String to encode |
key | Secret key |
salt | False deterministic · True random salt · str custom hex salt (8–32 chars) |
| Param | Description |
|---|---|
encoded_text | Previously encoded string |
key | Must match encoding key |
encode("text", "") # ValueError: Key must not be empty
decode(enc, "wrong_key") # Returns garbled text (no error)
decode("invalid!!!", "k")# ValueError: Invalid character
salt=True or a proper library like cryptography.