Expand description

This crate allows for the computation of cryptographic hashes or arbitrary data structures.

It provides a Fingerprint trait which represents a type whose hash can be computed. It’s implemented by default for most common types from std.

It relies on traits from the digest crate, which means its compatible with all hash implementations from the Rust Crypto project.

Hashes are considered stable, changes to how a given data structure is hashed will cause a minor version bump. Note that making a change to your own type definitions might introduce hash collisions. To avoid this, you can include a version number in your data structures.

You can include your crate version like this:

use blake2::Blake2b512;
use fingerprint_struct::fingerprint;

let payload = "Hello world!";
let hash = fingerprint::<Blake2b512>((env!("CARGO_PKG_VERSION"), payload));

Traits

A data structure whose cryptographic hash can be computed by a hasher.

Functions

Calculate the cryptographic hash of a data structure using the default hasher of a given type.
Calculate the cryptographic hash of a data structure using provided hasher.

Derive Macros

Implements the Fingerprint trait for a custom struct or enum.