1 2 3 4 5 6 7 8 9 10 11 12 13
#[allow(clippy::module_inception)]
pub mod hash;
mod hash_type;
pub use hash_type::HashType;
pub fn digest(data: &[u8], hash_type: HashType) -> Vec<u8> {
let result = match hash_type {
HashType::SHA1 => ring::digest::digest(&ring::digest::SHA1_FOR_LEGACY_USE_ONLY, data),
HashType::SHA256 => ring::digest::digest(&ring::digest::SHA256, data),
};
result.as_ref().to_vec()
}