Sha3::shake128/256

hi
I want to use the 'shake128/256' hash algorithm but I have a problem to use that
in other SHA algorithms in Rust first, create a new() variable and then use that to set input.
but in shake128 new() is not exist.
I don'n know to how to use shake128/256
please help me .thanks
this my code:

use sha3::{Digest, Shake128};
fn main() {
    let input = b"hello world";
    let mut hasher = Shake128::new();
    hasher.input(input);
    let hashed = hasher.result();
    println!("{:?}",hashed);
}

https://docs.rs/sha3/0.8.2/sha3/struct.Shake128.html#impl-Default

It implements Default trait, so you can use it to create default value for the type.

    let mut hasher = sha3::Shake128::default();
    // or:
    let mut hasher2: sha3::Shake128 = Default::default();
1 Like

Thank you :pray:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.