#[cfg(feature = "contract-address-double-key-hash")]
pub mod double_key_hash;
mod error;
#[cfg(feature = "contract-address-key-hash")]
pub mod key_hash;
#[cfg(feature = "contract-address-triple-key-hash")]
pub mod triple_key_hash;
pub use crate::contract::address::error::AddresserError;
use sha2::{Digest, Sha512};
pub const ADDRESS_LENGTH: usize = 70;
pub trait Addresser<K> {
fn compute(&self, key: &K) -> Result<String, AddresserError>;
fn normalize(&self, key: &K) -> String;
}
pub fn hash(hash_length: usize, key: &str) -> String {
let mut sha = Sha512::new();
sha.update(key.as_bytes());
hex::encode(sha.finalize())[..hash_length].to_string()
}