Crate khash[−][src]
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
ctx
andsalt
modules).
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.
let input = "Hello world!"; let mnemonic: String = Digest::new(&mut input.as_bytes()).collect(); // Read the bytes from the `input` string and collect the kana mnemonic into a `String`
Modules
ctx | Contains contexts used for the digest algorithms. |
error | Error for kana-hash operation |
salt | Salt for the digest |
Structs
Digest | A streaming kana hash digest. |
Functions
generate | Generate kana hash from a slice of bytes with this digest. |
generate_stream | Generate kana hash from a stream of bytes with this digest. |
khash_clone_context⚠ | Clone a context |
khash_clone_salt⚠ | Clone a salt |
khash_do⚠ | Compute and write a kana hash output to a string. |
khash_free_context⚠ | Free a context |
khash_free_salt⚠ | Free a salt allocated with |
khash_length⚠ | Calculate the length in bytes of a kana hash output. |
khash_max_length⚠ | Find the maximum length possible for a given algorithm’s output. |
khash_new_context⚠ | Create a new context |
khash_new_salt⚠ | Create a new salt |