pub trait Digest {
// Required methods
fn input(&mut self, input: &[u8]);
fn result(&mut self, out: &mut [u8]);
fn reset(&mut self);
fn output_bits(&self) -> usize;
fn block_size(&self) -> usize;
// Provided methods
fn output_bytes(&self) -> usize { ... }
fn input_str(&mut self, input: &str) { ... }
fn result_str(&mut self) -> String { ... }
}
Expand description
The Digest trait specifies an interface common to digest functions, such as SHA-1 and the SHA-2 family of digest functions.
Required Methods§
Sourcefn result(&mut self, out: &mut [u8])
fn result(&mut self, out: &mut [u8])
Retrieve the digest result. This method may be called multiple times.
§Arguments
- out - the vector to hold the result. Must be large enough to contain output_bits().
Sourcefn reset(&mut self)
fn reset(&mut self)
Reset the digest. This method must be called after result() and before supplying more data.
Sourcefn output_bits(&self) -> usize
fn output_bits(&self) -> usize
Get the output size in bits.
Sourcefn block_size(&self) -> usize
fn block_size(&self) -> usize
Get the block size in bytes.
Provided Methods§
Sourcefn output_bytes(&self) -> usize
fn output_bytes(&self) -> usize
Get the output size in bytes.
Sourcefn input_str(&mut self, input: &str)
fn input_str(&mut self, input: &str)
Convenience function that feeds a string into a digest.
§Arguments
input
The string to feed into the digest
Sourcefn result_str(&mut self) -> String
fn result_str(&mut self) -> String
Convenience function that retrieves the result of a digest as a String in hexadecimal format.