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-10/

Hash Format Converter

A utility for computing file hashes and providing them in different output formats.

Requirements

Build a utility function that computes the hash of a file and provides the hash in multiple output formats. The function should:

  1. Accept a file path as input
  2. Compute a 64-bit hash of the file contents
  3. Return the hash in three different formats:
    • Raw binary bytes (big-endian representation)
    • Hexadecimal string (lowercase)
    • Integer representation

API

def compute_hash_formats(file_path: str) -> dict:
    """
    Computes a 64-bit hash of the file and returns it in multiple formats.

    Args:
        file_path: Path to the file to hash

    Returns:
        Dictionary with keys 'bytes', 'hex', and 'int' containing the hash in each format

    Raises:
        FileNotFoundError: If the file does not exist
    """

Test Cases

  • Given a file containing "hello world", the function returns a dictionary with all three format types (bytes, hex, int) and the hex value matches the bytes value when converted @test
  • Given the same file hashed twice, all three formats (bytes, hex, int) are consistent with each other - hex is the hexadecimal representation of bytes, and int equals bytes interpreted as big-endian integer @test
  • Given an empty file, the function returns valid hashes in all three formats @test
  • Given a file that does not exist, the function raises FileNotFoundError @test

Implementation

@generates

Dependencies { .dependencies }

xxhash { .dependency }

Provides fast non-cryptographic hash algorithms with support for multiple output formats.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-xxhash

tile.json