Skip to main content

Sha3_256

Struct Sha3_256 

Source
pub struct Sha3_256 { /* private fields */ }
Expand description

SHA3-256 hash function (FIPS 202, Section 6.1).

Rate = 136 bytes (1088 bits), capacity = 64 bytes (512 bits), output = 32 bytes (256 bits).

Implementations§

Source§

impl Sha3_256

Source

pub const DIGEST_LEN: usize = 32

Output digest length in bytes (32).

Source

pub const fn new() -> Self

Creates a new SHA3-256 hasher.

Source

pub fn update(&mut self, data: &[u8])

Absorbs data into the hasher state.

Source

pub fn finalize(self) -> [u8; 32]

Finalizes the hash and returns the 32-byte digest.

Finalizes self.sponge in place via &mut so Drop zeroizes the caller’s original sponge storage (state and input buffer) without creating an unzeroized stack copy.

Source

pub fn digest(data: &[u8]) -> [u8; 32]

Computes SHA3-256(data) in one shot.

Source

pub fn digest_chunks(chunks: &[&[u8]]) -> [u8; 32]

Computes SHA3-256(chunks[0] || chunks[1] || ...) in one shot.

Inputs shorter than one rate block (< 136 bytes) absorb directly into an in-place Keccak state without allocating an intermediate byte buffer or copying the state on return.

Trait Implementations§

Source§

impl Default for Sha3_256

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Zeroize for Sha3_256

Source§

fn zeroize(&mut self)

Overwrites all sensitive memory owned by self with zeros.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.