Crate rattler_digest

Crate rattler_digest 

Source
Expand description

A module that provides utility functions for computing hashes using the RustCrypto/hashes library.

This module provides several functions that wrap around the hashing algorithms provided by the RustCrypto library. These functions allow you to easily compute the hash of a file, or a stream of bytes using a variety of hashing algorithms.

By utilizing the Digest trait, any hashing algorithm that implements that trait can be used with the functions provided in this crate.

§Examples

use rattler_digest::{compute_bytes_digest, compute_file_digest};
use sha2::Sha256;
use md5::Md5;

// Compute the MD5 hash of a string
let md5_result = compute_bytes_digest::<Md5>("Hello, world!");
println!("MD5 hash: {:x}", md5_result);

// Compute the SHA256 hash of a file
let sha256_result = compute_file_digest::<Sha256>("somefile.txt").unwrap();
println!("SHA256 hash: {:x}", sha256_result);

§Available functions

For more information on the hashing algorithms provided by the RustCrypto/hashes library, see the documentation for that library.

Re-exports§

pub use digest;

Modules§

serde
Provides custom serialization/deserialization functions for Output of a Digest.

Structs§

HashingReader
A simple object that provides a Read implementation that also immediately hashes the bytes read from it. Call HashingReader::finalize to retrieve both the original impl Read object as well as the hash.
HashingWriter
A simple object that provides a Write implementation that also immediately hashes the bytes written to it. Call HashingWriter::finalize to retrieve both the original impl Write object as well as the hash.

Functions§

compute_bytes_digest
Compute a hash of the specified bytes.
compute_file_digest
Compute a hash of the file at the specified location.
compute_url_digest
Compute a hash of the specified Url without basic auth.
parse_digest_from_hex
Parses a hash hex string to a digest.

Type Aliases§

Blake2b256
A type for a 32 bit length blake2b digest.
Blake2b256Hash
A type alias for the output of a Blake2b256 hash.
Blake2bMac256
A type alias for the output of a blake2b256 hash.
Blake2bMac256Hash
A type alias for the output of a Blake2bMac256 hash.
Md5
MD5 hasher state.
Md5Hash
A type alias for the output of an MD5 hash.
Sha256
SHA-256 hasher.
Sha256Hash
A type alias for the output of a SHA256 hash.