5 stable releases

2.0.4 Mar 20, 2021
2.0.2 Feb 6, 2021
2.0.0 Sep 17, 2020

#9 in #kana

GPL-3.0-or-later

30MB
2K SLoC

Rust 1.5K SLoC // 0.0% comments Common Lisp 177 SLoC C 155 SLoC JavaScript 138 SLoC // 0.1% comments

Contains (static library, 27MB) cli/lib/libkhash.a, (ELF lib, 3.5MB) cli/lib/libkhash.so

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 and salt 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` 

Dependencies