def check_hash(file_path: Path, expected_hash: str, algorithm: str = "sha256") -> None:
    """Verify that a file's hash matches the expected value.

    Args:
        file_path: Path to file to check
        expected_hash: Expected hash value
        algorithm: Hashing algorithm to use

    Raises:
        ValueError: If the calculated hash does not match the expected hash
    """
    # Compare the calculated hash with the expected hash
    calculated_hash = generate_hash(file_path, algorithm)
    if calculated_hash != expected_hash:
        msg = (
            f"Calculated hash {calculated_hash} of downloaded file {file_path} "
            f"does not match the required hash {expected_hash}."
        )
        raise ValueError(msg)
Verify that a file's hash matches the expected value.

    Args:
        file_path: Path to file to check
        expected_hash: Expected hash value
        algorithm: Hashing algorithm to use

    Raises:
        ValueError: If the calculated hash does not match the expected hash
    
src/anomalib/data/utils/download.py