use blake2::digest::core_api::RtVariableCoreWrapper;
use blake2::digest::{Update, VariableOutput};
use blake2::Blake2bVar;
use hex;
pub fn blake2b_224(data: &str) -> String {
let decoded_data: Vec<u8> = if let Ok(decoded) = hex::decode(data) {
decoded
} else {
data.as_bytes().to_vec()
};
let mut hasher: RtVariableCoreWrapper<blake2::Blake2bVarCore> =
Blake2bVar::new(28).expect("Failed to create BLAKE2b hasher");
hasher.update(&decoded_data);
let mut result: [u8; 28] = [0u8; 28];
hasher
.finalize_variable(&mut result)
.expect("Failed to finalize hash");
hex::encode(result)
}