khash - Kana mnemonic hashes
This library pretty prints salted hashes of a veriaty of digests in kana. Mnemonics can be generated from slices or from streams.
It has a Rust API documented here, as well as C FFI bindings and a C header (see include/.)
Digest
The digests available are:
- SHA256 truncated to the first 64 bits (8 bytes) (default digest)
- SHA256 full
- CRC64 (requires "crc" default feature enabled)
- CRC32 (requires "crc" default feature enabled)
Salting
The salting options for the digests are:
- Hard-coded embedded 32 byte salt (default)
- Fixed compile time 32 byte salt
- Fixed runtime 32 byte salt
- Dynamically sized runtime salt
- No salt
The salt (if any) is fed into the digest directly after all the data.
(See
ctxandsaltmodules).
Generating kana mnemonics from arbitrary data
To use the mnemonic generation algorithm on any binary data instead of just hash outputs, the Digest iterator type is provided.
The Digest iterator can be created from any type implementing std::io::Read and produces a kana mnemonic reading from the stream until its end.
# use Digest;
let input = "Hello world!";
let mnemonic: String = new.collect; // Read the bytes from the `input` string and collect the kana mnemonic into a `String`