""" Blake3 Hash Utilities Provides Blake3 hash computation for file integrity verification. """ from typing import Union def compute_blake3(content: bytes) -> str: """ Compute Blake3 hash of content. Args: content: File bytes Returns: Hex string (lowercase) Raises: ImportError: If blake3 module not installed """ try: import blake3 except ImportError: raise ImportError( "blake3 module not installed. Install with: pip install blake3" ) hasher = blake3.blake3() hasher.update(content) return hasher.hexdigest() def verify_blake3(content: bytes, expected_hash: str) -> bool: """ Verify Blake3 hash of content. Args: content: File bytes expected_hash: Expected hex hash (lowercase) Returns: True if hash matches, False otherwise """ computed = compute_blake3(content) return computed.lower() == expected_hash.lower()