4 releases
| new 0.1.3 | Jan 31, 2026 |
|---|---|
| 0.1.2 | Dec 9, 2025 |
| 0.1.1 | Dec 9, 2025 |
| 0.1.0 | Dec 9, 2025 |
#969 in Cryptography
23KB
359 lines
UniAz 🔐
UniAz is a small Rust crate that provides a simple, Unicode-aware way to encode a single Unicode character into the alphabet and recover it back. It combines a base converter and a light-weight cipher permutation to produce obfuscated string representations of characters. It is intended to provide a readable, mappable, and easy-to-remember alternative representation for non‑ASCII characters in situations where they might otherwise become garbled.
Key features
- 🔁 Encrypt and decrypt individual Unicode characters via
UniAz. - 🧩 Uses the normal latin alphabet in ascii(A–Z).
- ⚡ Lightweight: single-file API for easy integration and testing.
Installation
cargo add uniaz
Quick example
use uniaz::UniAz;
fn main() {
let uni = UniAz::new(); // "abcdefghijklmnopqrstuvwxyz"
let encrypted = uni.encrypt('你'); // -> "abpx"
let decrypted = uni.decrypt(&encrypted).unwrap(); // -> '你'
println!("encrypted={encrypted}");
assert_eq!(decrypted, '你');
// Batch encrypt/decrypt strings (space-separated tokens)
let text = uni.encrypt_str("你好世界");
let recovered = uni.decrypt_str(&text).unwrap();
assert_eq!(recovered, "你好世界");
}
API (important)
UniAz::new()/UniAz::default()— create an instance.UniAz::encrypt(char) -> String— convert a char to an encrypted string.UniAz::decrypt(&str) -> Result<char, DecryptError>— recover the original char (returnsErron invalid input).UniAz::encrypt_str(&str) -> String— encrypt a string (space-separated output).UniAz::decrypt_str(&str) -> Result<String, DecryptError>— decrypt a string.
Docs & tests
- Generate and open the API docs:
cargo doc --open
License
- MIT OR Apache-2.0.
Enjoy! 🚀
Dependencies
~20KB