hashmoji

Crates.iohashmoji
lib.rshashmoji
version0.1.0
sourcesrc
created_at2023-11-07 03:39:41.13846
updated_at2023-11-07 03:39:41.13846
descriptionProvides a hash functions that returns emojis.
homepage
repositoryhttps://github.com/gak/hashmoji
max_upload_size
id1027561
size29,372
gak (gak)

documentation

README

hashmoji

hashmoji is a crate that generates deterministic unique emojis based on the hash of a value.

This is useful for generating unique emojis for a given value, such as a user ID, or a file hash, instead of looking at a random UUID.

hashmoji relies on the Hash trait to generate a unique emoji for a given value, which many types implement, and of course you can implement it for your own types using #[derive(Hash)].

Usage

let uuid = "30d8c256-0ffa-4e1b-8e1e-437bb0a0b45a";

// Generate a single emoji:
let emoji = hashmoji::one(uuid);
assert_eq!(emoji, "๐ŸŒค๏ธ");

// You can also generate a fixed length string:
let emoji = hashmoji::fixed(uuid, 10);
assert_eq!(emoji, "๐ŸŒค๏ธโ™Ž๐Ÿ˜Ÿ๐ŸŸฉโคต๏ธ๐Ÿ‡ฝ๐Ÿ‡ฐ๐Ÿ‡ง๐Ÿ‡ฆ๐Ÿ‰๐Ÿค ๐Ÿฆต");

// A variable length string, depending on the hash:
let emoji = hashmoji::variable(uuid, 3..7);
assert_eq!(emoji, "๐ŸŒค๏ธโ™Ž๐Ÿ˜Ÿ๐ŸŸฉ");

License

flea_bit is licensed under either the MIT license or the Apache-2.0 license, at your discretion.

Commit count: 27

cargo fmt