From 658c30fba641c9d47dc25d1ec67b77f42458280e Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 1 Dec 2019 17:08:46 +0100 Subject: [PATCH] examples: Add blake2b and simplify names. --- xmpp-parsers/examples/generate-caps.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/xmpp-parsers/examples/generate-caps.rs b/xmpp-parsers/examples/generate-caps.rs index 0d4594d0..a36963aa 100644 --- a/xmpp-parsers/examples/generate-caps.rs +++ b/xmpp-parsers/examples/generate-caps.rs @@ -16,16 +16,21 @@ use xmpp_parsers::{ }; fn get_caps(disco: &DiscoInfoResult, node: String) -> Result { - let caps_data = compute_disco_caps(&disco); - let caps_hash = hash_caps(&caps_data, Algo::Sha_1)?; - Ok(Caps::new(node, caps_hash)) + let data = compute_disco_caps(&disco); + let hash = hash_caps(&data, Algo::Sha_1)?; + Ok(Caps::new(node, hash)) } fn get_ecaps2(disco: &DiscoInfoResult) -> Result { - let ecaps2_data = compute_disco_ecaps2(&disco)?; - let ecaps2_sha256 = hash_ecaps2(&ecaps2_data, Algo::Sha_256)?; - let ecaps2_sha3_256 = hash_ecaps2(&ecaps2_data, Algo::Sha3_256)?; - Ok(ECaps2::new(vec![ecaps2_sha256, ecaps2_sha3_256])) + let data = compute_disco_ecaps2(&disco)?; + let hash_sha256 = hash_ecaps2(&data, Algo::Sha_256)?; + let hash_sha3_256 = hash_ecaps2(&data, Algo::Sha3_256)?; + let hash_blake2b_256 = hash_ecaps2(&data, Algo::Blake2b_256)?; + Ok(ECaps2::new(vec![ + hash_sha256, + hash_sha3_256, + hash_blake2b_256, + ])) } fn main() -> Result<(), Box> {