2 releases
0.1.1 | Sep 19, 2024 |
---|---|
0.1.0 | Sep 16, 2024 |
#595 in Encoding
37 downloads per month
30KB
579 lines
KittenMoji
This is a KittenMoji encoder/decoder written in rust.
This crate is written in 100% safe rust and has no external dependencies.
What is KittenMoji?
KittenMoji is a base 256 binary-to-text encoding that uses emojis as encoding units. It originates from the Small Web development kit Kitten, where it is used to encode cryptographic keys.
Why?
You can say a lot of things against KittenMoji. For example, it is terribly inefficient. Even a hexadecimal binary-to-text encoding encodes each byte as only two bytes. KittenMoji, encoded as utf-8, uses 4 bytes per byte.
However, it looks nice, it's kind of cute and someone on Mastodon pointed out that many platforms with character limits (e.g. Mastodon) count emojis as only one character.
Personally, I just wrote this crate for the joy of it, not for any practical use.
Usage
Example usage in rust code
let kitten_encoded = encode_slice(b"kitten");
assert_eq!(kitten_encoded, "π§¬ππΊπΊππ");
let kitten_decoded = decode_str("π§¬ππΊπΊππ").unwrap();
assert_eq!(kitten_decoded, b"kitten");
Example binaries
There are two example binaries: encode
and decode
. They take input from stdin, encode/decode it and write the result to stdin. Both have a constant memory footprint and can be used to encode or decode large files.
echo -n "kitten" | cargo run --release --example encode
License
This project is licensed under the GNU Affero General Public License.