usesuper::{FixedOutput, FixedOutputReset, InvalidBufferSize, Reset, Update}; use crypto_common::{typenum::Unsigned, Output, OutputSizeUser};
#[cfg(feature = "alloc")] use alloc::boxed::Box;
/// Marker trait for cryptographic hash functions. pubtrait HashMarker {}
/// Convenience wrapper trait covering functionality of cryptographic hash /// functions with fixed output size. /// /// This trait wraps [`Update`], [`FixedOutput`], [`Default`], and /// [`HashMarker`] traits and provides additional convenience methods. pubtrait Digest: OutputSizeUser { /// Create new hasher instance. fn new() -> Self;
/// Create new hasher instance which has processed the provided data. fn new_with_prefix(data: impl AsRef<[u8]>) -> Self;
/// Process data, updating the internal state. fn update(&mutself, data: impl AsRef<[u8]>);
/// Process input data in a chained manner. #[must_use] fn chain_update(self, data: impl AsRef<[u8]>) -> Self;
/// Retrieve result and consume hasher instance. fn finalize(self) -> Output<Self>;
/// Write result into provided array and consume the hasher instance. fn finalize_into(self, out: &mut Output<Self>);
/// Retrieve result and reset hasher instance. fn finalize_reset(&mutself) -> Output<Self> where Self: FixedOutputReset;
/// Write result into provided array and reset the hasher instance. fn finalize_into_reset(&mutself, out: &mut Output<Self>) where Self: FixedOutputReset;
/// Reset hasher instance to its initial state. fn reset(&mutself) where Self: Reset;
/// Get output size of the hasher fn output_size() -> usize;
/// Modification of the [`Digest`] trait suitable for trait objects. pubtrait DynDigest { /// Digest input data. /// /// This method can be called repeatedly for use with streaming messages. fn update(&mutself, data: &[u8]);
/// Retrieve result and reset hasher instance #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] fn finalize_reset(&mutself) -> Box<[u8]> { letmut result = vec![0; self.output_size()]; self.finalize_into_reset(&mut result).unwrap();
result.into_boxed_slice()
}
/// Write result into provided array and consume the hasher instance. /// /// Returns error if buffer length is not equal to `output_size`. fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>;
/// Write result into provided array and reset the hasher instance. /// /// Returns error if buffer length is not equal to `output_size`. fn finalize_into_reset(&mutself, out: &mut [u8]) -> Result<(), InvalidBufferSize>;
/// Reset hasher instance to its initial state. fn reset(&mutself);
/// Get output size of the hasher fn output_size(&self) -> usize;
/// Clone hasher state into a boxed trait object #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] fn box_clone(&self) -> Box<dyn DynDigest>;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.