Simple dynamic trait-object based hashing library
This library allows you to define a thin non-generic interface, over which you can pass various hashes and hash functions. This is done using Trait Objects.
While every crate can define and implement custom Hash / HashType structs, this library has built-in support for the
- sha3
- sha2
crates.
These can be enabled by the "sha2" or "sha3" features respectively.
Example
Let's suppose you're writing a web-server library that accepts a hash from a client. The hash and hash type are passed as a byte slice and &str respectively. The web-server shouldn't have any knowledge about the allowed hash types, these can be passed in at runtime:
use ;
This allows the web-server library to support all kinds of hashes, that the higher-level crate chooses to support.