use seal_crypto_wrapper::error::Result;
use seal_crypto_wrapper::prelude::*;
fn main() -> Result<()> {
println!("--- Running Hashing Example ---");
let algorithm = HashAlgorithm::build().sha256();
println!("Selected hash algorithm: {:?}", algorithm);
let hasher = algorithm.into_wrapper();
println!("Got hash wrapper.");
let data_to_hash = b"This is the data to be hashed.";
println!("Data to hash: {:?}", String::from_utf8_lossy(data_to_hash));
let digest = hasher.hash(data_to_hash);
println!("Hashed data (digest): {:x?}", digest);
assert_eq!(digest.len(), 32);
println!("--- Hashing Example Finished ---\n");
println!("--- Running HMAC Example ---");
let hmac_algorithm = HashAlgorithm::build().sha512();
println!("Selected HMAC algorithm: {:?}", hmac_algorithm);
let hmac_hasher = hmac_algorithm.into_wrapper();
let hmac_key = b"my-super-secret-hmac-key";
let message = b"This message is to be authenticated.";
println!("HMAC key: (hidden for security)");
println!("Message to authenticate: {:?}", String::from_utf8_lossy(message));
let mac = hmac_hasher.hmac(hmac_key, message)?;
println!("Computed HMAC tag: {:x?}", mac);
assert_eq!(mac.len(), 64);
let verification_mac = hmac_hasher.hmac(hmac_key, message)?;
assert_eq!(mac, verification_mac);
println!("Successfully verified HMAC tag.");
println!("--- HMAC Example Finished ---");
Ok(())
}