Struct Keccak

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

An implementation of keccak functions. The Keccak reference.

§Example

[dependencies]
keccak-rust = *
extern crate keccak_rust;
use keccak_rust::*;

const YOUR_INPUT_BYTES: [u8; 12] = [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33];

fn main() {
    let mut keccak = Keccak::new(SecurityLevel::SHA256, StateBitsWidth::F1600);
    keccak.append(&mut YOUR_INPUT_BYTES);
    println!("{:?}", keccak.hash());
}

Implementations§

Source§

impl Keccak

Source

pub fn new(security: SecurityLevel, width: StateBitsWidth) -> Keccak

Creates a new keccak state with a provided security level and state bits width.

Possible securities levels:

  • SHA224 (224 bit)
  • SHA256 (256 bit)
  • SHA384 (384 bit)
  • SHA512 (512 bit)

Possible state bits widths:

  • f25
  • f50
  • f100
  • f200
  • f400
  • f800
  • f1600
Source

pub fn append(&mut self, input: &BytesArr)

Appends input to current state

Source

pub fn hash(&mut self) -> BytesVec

Returns keccak hash based on current state

Auto Trait Implementations§

§

impl Freeze for Keccak

§

impl RefUnwindSafe for Keccak

§

impl Send for Keccak

§

impl Sync for Keccak

§

impl Unpin for Keccak

§

impl UnwindSafe for Keccak

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 = 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 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.