Crates.io | kittenmoji |
lib.rs | kittenmoji |
version | 0.1.1 |
source | src |
created_at | 2024-09-16 17:38:15.289076 |
updated_at | 2024-09-19 18:31:39.042553 |
description | A crate to encode and decode kittenmoji. |
homepage | |
repository | https://gitlab.com/GKnirps/kittenmoji-rust |
max_upload_size | |
id | 1376649 |
size | 66,187 |
This is a KittenMoji encoder/decoder written in rust.
This crate is written in 100% safe rust and has no external dependencies.
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.
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.
let kitten_encoded = encode_slice(b"kitten");
assert_eq!(kitten_encoded, "π§¬ππΊπΊππ");
let kitten_decoded = decode_str("π§¬ππΊπΊππ").unwrap();
assert_eq!(kitten_decoded, b"kitten");
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
This project is licensed under the GNU Affero General Public License.