Module cryptoxide::hashing

source ·
Expand description

Cryptographic Hash Functions root module

The simplest way to use this module is to use the function, named after each algorithm, that calculate the digest in one single call:

use cryptoxide::hashing::sha256;

let digest = sha256(b"The quick brown fox jumps over the lazy dog");

Each individual algorithm is also available as a module that should be imported qualified and export algorithm singleton for each variant of this algorithm along with a Context object.

The Context object keeps the ongoing state of the algorithm, so that the input can be hashed incrementally with either update or update_mut. Once all the data has been hashed the Context can be finalized using finalize or finalize_reset.

The APIs can be used either in a pass-the-context api:

use cryptoxide::hashing::sha2;

let digest = sha2::Context256::new()
        .update(b"The quick brown fox jumps over the lazy dog")
        .update(b"other data")
        .finalize();

Or using the inplace mutable APIs:

use cryptoxide::hashing::sha2;

let mut context = sha2::Context256::new();
context.update_mut(b"The quick brown fox jumps over the lazy dog");
context.update_mut(b"other data");
let digest = context.finalize_reset();

Modules

Blake2B hash function
Blake2S hash function
An implementation of the Keccak cryptographic hash algorithms.
An implementation of the RIPEMD-160 cryptographic hash.
An implementation of the SHA-1 cryptographic hash algorithm.
An implementation of the SHA-2 cryptographic hash algorithms.
An implementation of the SHA-3 cryptographic hash algorithms.

Functions

Compute blake2b-224 on the input and return the digest
Compute blake2b-256 on the input and return the digest
Compute blake2b-384 on the input and return the digest
Compute blake2b-512 on the input and return the digest
Compute blake2s-224 on the input and return the digest
Compute blake2s-256 on the input and return the digest
Compute KECCAK224 on the input and return the digest
Compute KECCAK256 on the input and return the digest
Compute KECCAK384 on the input and return the digest
Compute KECCAK512 on the input and return the digest
Compute RIPEMD160 on the input and return the digest
Compute SHA1 on the input and return the digest
Compute SHA3-224 on the input and return the digest
Compute SHA3-256 on the input and return the digest
Compute SHA3-384 on the input and return the digest
Compute SHA3-512 on the input and return the digest
Compute SHA224 on the input and return the digest
Compute SHA256 on the input and return the digest
Compute SHA384 on the input and return the digest
Compute SHA512 on the input and return the digest