pub struct Sha256 { /* private fields */ }Expand description
SHA-256 hasher.
Buffers input into 64-byte blocks and drives the hardware sha2 compression
(runtime-detected on AArch64) or the sha2 crate’s
compression function, which selects hardware SHA-256 instructions at
runtime where available. The state and any buffered input are wiped when
the hasher is dropped.
Implementations§
Source§impl Sha256
impl Sha256
Sourcepub fn compute_into_bytes<Output: MutByteArray<CRYPTO_HASH_SHA256_BYTES>, Input: Bytes + ?Sized>(
output: &mut Output,
input: &Input,
)
pub fn compute_into_bytes<Output: MutByteArray<CRYPTO_HASH_SHA256_BYTES>, Input: Bytes + ?Sized>( output: &mut Output, input: &Input, )
One-time interface to compute SHA-256 digest for input, copying result
into output.
Sourcepub fn compute<Output: NewByteArray<CRYPTO_HASH_SHA256_BYTES>, Input: Bytes + ?Sized>(
input: &Input,
) -> Output
pub fn compute<Output: NewByteArray<CRYPTO_HASH_SHA256_BYTES>, Input: Bytes + ?Sized>( input: &Input, ) -> Output
One-time interface to compute SHA-256 digest for input.
Sourcepub fn compute_to_vec<Input: Bytes + ?Sized>(input: &Input) -> Vec<u8> ⓘ
Available on crate feature alloc only.
pub fn compute_to_vec<Input: Bytes + ?Sized>(input: &Input) -> Vec<u8> ⓘ
alloc only.Wrapper around Sha256::compute, returning a Vec. Provided for
convenience.
Sourcepub fn update<Input: Bytes + ?Sized>(&mut self, input: &Input)
pub fn update<Input: Bytes + ?Sized>(&mut self, input: &Input)
Updates SHA-256 hash state with input.
Sourcepub fn finalize<Output: NewByteArray<CRYPTO_HASH_SHA256_BYTES>>(self) -> Output
pub fn finalize<Output: NewByteArray<CRYPTO_HASH_SHA256_BYTES>>(self) -> Output
Consumes hasher and return final computed hash.
Sourcepub fn finalize_into_bytes<Output: MutByteArray<CRYPTO_HASH_SHA256_BYTES>>(
self,
output: &mut Output,
)
pub fn finalize_into_bytes<Output: MutByteArray<CRYPTO_HASH_SHA256_BYTES>>( self, output: &mut Output, )
Consumes hasher and writes final computed hash into output.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sha256
impl RefUnwindSafe for Sha256
impl Send for Sha256
impl Sync for Sha256
impl Unpin for Sha256
impl UnsafeUnpin for Sha256
impl UnwindSafe for Sha256
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more