Pure Rust implementation of the MD6 hash function.
use md6::Md6_256;
use digest::Digest;
use hex_literal::hex;
// create a Md6_256 object
let mut hasher = Md6_256::new();
// write input message
hasher.update(b"hello world");
// read hash digest and consume hasher
let hash = hasher.finalize();
assert_eq!(hash.to_vec(), hex!(
"9ae602639631cc2c60adaa7a952aae8756141f31a7e6a9b76adc1de121db2230"
));Also, see the [examples section] in the RustCrypto/hashes readme.
This implementation supports run and compile time variable sizes.
Output size set at run time:
use md6::Md6Var;
use digest::{Update, VariableOutput};
use hex_literal::hex;
let mut hasher = Md6Var::new(12).unwrap();
hasher.update(b"hello rust");
let mut buf = [0u8; 12];
hasher.finalize_variable(&mut buf).unwrap();
assert_eq!(buf, hex!("9c5b8d9744898ec981bcc573"));Output size set at compile time:
use md6::Md6;
use digest::{Digest, consts::U20};
use hex_literal::hex;
type Md6_160 = Md6<U20>;
let mut hasher = Md6_160::new();
hasher.update(b"hello rust");
let res = hasher.finalize();
assert_eq!(res, hex!("576d736a93a555a1c868973cfdd2d21838a26623"));The crate is licensed under either of:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.