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
227 downloads per month
17KB
413 lines
Two-Ten
Another silly human readable digest tool
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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
to377
.
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