Module 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
Blake2B hash function
blake2s
Blake2S hash function
keccak
An implementation of the Keccak cryptographic hash algorithms.
ripemd160
An implementation of the RIPEMD-160 cryptographic hash.
sha1
An implementation of the SHA-1 cryptographic hash algorithm.
sha2
An implementation of the SHA-2 cryptographic hash algorithms.
sha3
An implementation of the SHA-3 cryptographic hash algorithms.

Functions§

blake2b_224
Compute blake2b-224 on the input and return the digest
blake2b_256
Compute blake2b-256 on the input and return the digest
blake2b_384
Compute blake2b-384 on the input and return the digest
blake2b_512
Compute blake2b-512 on the input and return the digest
blake2s_224
Compute blake2s-224 on the input and return the digest
blake2s_256
Compute blake2s-256 on the input and return the digest
keccak224
Compute KECCAK224 on the input and return the digest
keccak256
Compute KECCAK256 on the input and return the digest
keccak384
Compute KECCAK384 on the input and return the digest
keccak512
Compute KECCAK512 on the input and return the digest
ripemd160
Compute RIPEMD160 on the input and return the digest
sha1
Compute SHA1 on the input and return the digest
sha3_224
Compute SHA3-224 on the input and return the digest
sha3_256
Compute SHA3-256 on the input and return the digest
sha3_384
Compute SHA3-384 on the input and return the digest
sha3_512
Compute SHA3-512 on the input and return the digest
sha224
Compute SHA224 on the input and return the digest
sha256
Compute SHA256 on the input and return the digest
sha384
Compute SHA384 on the input and return the digest
sha512
Compute SHA512 on the input and return the digest