Struct tiny_keccak::Sha3

source ·
pub struct Sha3 { /* private fields */ }
Expand description

The SHA3 hash functions defined in FIPS-202.

Usage

[dependencies]
tiny-keccak = { version = "2.0.0", features = ["sha3"] }

Example

let input = b"hello world";
let mut output = [0; 32];
let expected = b"\
    \x64\x4b\xcc\x7e\x56\x43\x73\x04\x09\x99\xaa\xc8\x9e\x76\x22\xf3\
    \xca\x71\xfb\xa1\xd9\x72\xfd\x94\xa3\x1c\x3b\xfb\xf2\x4e\x39\x38\
";
let mut sha3 = Sha3::v256();
sha3.update(input);
sha3.finalize(&mut output);
assert_eq!(expected, &output);

Implementations§

source§

impl Sha3

source

pub fn v224() -> Sha3

Creates new Sha3 hasher with a security level of 224 bits.

source

pub fn v256() -> Sha3

Creates new Sha3 hasher with a security level of 256 bits.

source

pub fn v384() -> Sha3

Creates new Sha3 hasher with a security level of 384 bits.

source

pub fn v512() -> Sha3

Creates new Sha3 hasher with a security level of 512 bits.

Trait Implementations§

source§

impl Clone for Sha3

source§

fn clone(&self) -> Sha3

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Hasher for Sha3

source§

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

Absorb additional input. Can be called multiple times.
source§

fn finalize(self, output: &mut [u8])

Pad and squeeze the state to the output.

Auto Trait Implementations§

§

impl RefUnwindSafe for Sha3

§

impl Send for Sha3

§

impl Sync for Sha3

§

impl Unpin for Sha3

§

impl UnwindSafe for Sha3

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.