Function crypto_hash::digest [] [src]

pub fn digest(algorithm: Algorithm, data: Vec<u8>) -> Vec<u8>

Helper function for Hasher which generates a cryptographic digest from the given data and algorithm.

Examples

use crypto_hash::{Algorithm, digest};

let data = b"crypto-hash".to_vec();
let result = digest(Algorithm::SHA256, data);
let expected =
    b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'"
    .to_vec();
assert_eq!(expected, result)