3 unstable releases

0.2.1 Feb 10, 2025
0.2.0 Feb 10, 2025
0.1.0 Dec 22, 2023

#79 in Value formatting

Download history 2/week @ 2024-10-29 3/week @ 2024-11-05 1/week @ 2024-12-03 16/week @ 2024-12-10 116/week @ 2025-02-04 111/week @ 2025-02-11

227 downloads per month

MIT/Apache

17KB
413 lines

Two-Ten

Documentation

Another silly human readable digest tool

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

twoten

Hash data into two bytes, and turn it into an (exactly) ten byte, human readable summary.

Summaries are:

  • A 16-bit fnv1a hash of the data
  • The first 8 bits of the hash are used to select a 6-character word. See WORDS.
  • The next 8 bits of the hash are formatted in an octal format, 000 to 377.

The resulting summary looks like JESTER-123

Example

// `twoten_buf` is available on no-std and makes a stack string
use twoten::twoten_buf;

let name = twoten_buf(b"Hello, world!");
assert_eq!("ALFRED-035", name.as_str());
// Supports AsRef conversions
let asref: &str = &name;
assert_eq!("ALFRED-035", asref);
// `twoten_string` is available on std and makes a heap string.
// requires the `use-std` feature.
use twoten::twoten_string;

let name: String = twoten_string(b"Hello, world!");
assert_eq!("ALFRED-035", name.as_str());

Features

Enable the use-std feature to activate std helpers

No runtime deps

Features