CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-xxhash

Python binding for xxHash library providing fast non-cryptographic hash algorithms

Overall
score

80%

Evaluation80%

1.03x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-2/

File Chunk Hasher

A utility that computes hash digests for large files by processing them in chunks.

Problem Description

Build a file chunk hasher that reads files incrementally and computes their hash digests without loading the entire file into memory. The hasher should support multiple output formats and allow users to verify file integrity by comparing hash values.

Requirements

Core Functionality

The system should provide a function that:

  • Accepts a file path and an optional chunk size parameter (default: 8192 bytes)
  • Reads the file in chunks of the specified size
  • Computes a hash digest for the entire file content
  • Returns the hash in three different formats: hexadecimal string, raw bytes, and integer

Output Formats

The function should return a dictionary/object containing:

  • hex: The hash as a hexadecimal string
  • bytes: The hash as raw bytes
  • int: The hash as an integer value

Error Handling

  • If the file does not exist, raise/throw an appropriate error
  • If the chunk size is less than 1, raise/throw a ValueError/error

Test Cases

  • Given a file containing "Hello, World!", compute its hash digest and verify all three output formats are non-empty strings/bytes/integers @test
  • Given a file with 20000 bytes of data, process it with a chunk size of 1024 and verify the hash is computed correctly @test
  • Given a non-existent file path, verify that an appropriate error is raised @test
  • Given a chunk size of 0, verify that a ValueError is raised @test

Implementation

@generates

API

def compute_file_hash(file_path: str, chunk_size: int = 8192) -> dict:
    """
    Computes hash digest for a file by reading it in chunks.

    Args:
        file_path: Path to the file to hash
        chunk_size: Number of bytes to read per chunk (default: 8192)

    Returns:
        Dictionary containing 'hex', 'bytes', and 'int' representations of the hash

    Raises:
        FileNotFoundError: If the file does not exist
        ValueError: If chunk_size is less than 1
    """
    pass

Dependencies { .dependencies }

xxhash { .dependency }

Provides fast non-cryptographic hash computation with streaming interface support.

Install with Tessl CLI

npx tessl i tessl/pypi-xxhash

tile.json