This crate provides a reusable functionality for working with typical cryptographic hashes.
# use FromStr;
# use Arc;
# use ;
#
let expected = "sha256_dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f";
// Parse the string representation of the expected hash.
let digest = from_str.unwrap;
assert_eq!;
assert_eq!;
// Compute a digest.
let mut hasher = digest.algorithm.hasher;
hasher.update;
assert_eq!;
For parsing, the string representation is expected to be in the format
<algorithm>_<digest> or <algorithm>:<digest>.
The algorithm must be one of the following:
sha256sha512_256orsha512-256sha512
Note that the underscore representation is preferred as it can be selected by double clicking in most applications.
In the future, we may add additional hash algorithms.
Features
This crate supports the following features:
serde: Enable serialization and deserialization support using Serde.legacy: Use legacy formatting and algorithm names for compatibility with older parsers.