"Some Crypto Text"; // Compute the HMAC. let mut ctx = MdCtx::new().unwrap(); ctx.digest_sign_init(Some(Md::sha256()), &key).unwrap(); ctx.digest_sign_update(text).unwrap(); let mut hmac = vec![]; ctx.digest_sign_final_to_vec(&mut hmac).unwrap(); // Verify the HMAC. You can't use MdCtx to do this; instead use a constant time equality check. # let target = hmac.clone(); let valid = memcmp::eq(&hmac, &target); assert!(valid); ```