pub fn data_digest(&self, data: &[u8]) -> Result<String, io::Error> {
        let mut hasher = match self {
            HashAlgorithm::Sha1 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA1),
            HashAlgorithm::Sha256 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA256),
            HashAlgorithm::Sha512 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA512),
        };
        hasher.write_all(data)?;
        let mut s = String::new();
        hasher
            .finish()
            .write_hex_upper(&mut s)
            .expect("HEX format failed");
        Ok(s)
    }
/// Returns the hash digest for `data` as a hexadecimal string.
Returns the hash digest for `data` as a hexadecimal string.
Returns the hash digest for ` data ` as a hexadecimal string .
pub fn data_digest(&self, data: &[u8]) -> Result<String, io::Error> {
        let mut hasher = match self {
            HashAlgorithm::Sha1 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA1),
            HashAlgorithm::Sha256 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA256),
            HashAlgorithm::Sha512 => crypto_hash::Hasher::new(crypto_hash::Algorithm::SHA512),
        };
        hasher.write_all(data)?;
        let mut s = String::new();
        hasher
            .finish()
            .write_hex_upper(&mut s)
            .expect("HEX format failed");
        Ok(s)
    }
pub fn data_digest ( & self , data : & [ u8 ] ) -> Result < String , io :: Error > { let mut hasher = match self { HashAlgorithm :: Sha1 => crypto_hash :: Hasher :: new ( crypto_hash :: Algorithm :: SHA1 ) , HashAlgorithm :: Sha256 => crypto_hash :: Hasher :: new ( crypto_hash :: Algorithm :: SHA256 ) , HashAlgorithm :: Sha512 => crypto_hash :: Hasher :: new ( crypto_hash :: Algorithm :: SHA512 ) , } ; hasher . write_all ( data ) ? ; let mut s = String :: new ( ) ; hasher . finish ( ) . write_hex_upper ( & mut s ) . expect ( " " ) ; Ok ( s ) }
Returns the hash digest for `data` as a hexadecimal string.
Returns the hash digest for ` data ` as a hexadecimal string .
&self
data
&[u8]