pub fn verify_hash_with_algorithm(
data: &[u8],
expected_hash: &str,
algorithm: &HashAlgorithm,
) -> boolExpand description
Verify hash with an explicitly specified algorithm
Use this when you know which algorithm was used to create the hash.
§Arguments
data- The data to verifyexpected_hash- The expected hash in hexadecimal formatalgorithm- The hash algorithm that was used
§Returns
trueif the data matches the hashfalseif the data doesn’t match
§Examples
use atlas_cli::hash::{calculate_hash_with_algorithm, verify_hash_with_algorithm};
use atlas_c2pa_lib::cose::HashAlgorithm;
let data = b"test data";
let hash = calculate_hash_with_algorithm(data, &HashAlgorithm::Sha384);
// Verification with correct algorithm succeeds
assert!(verify_hash_with_algorithm(data, &hash, &HashAlgorithm::Sha384));
// Verification with wrong algorithm fails
assert!(!verify_hash_with_algorithm(data, &hash, &HashAlgorithm::Sha256));