Python binding for xxHash library providing fast non-cryptographic hash algorithms
Overall
score
80%
Evaluation — 80%
↑ 1.03xAgent success when using this tile
Build a binary hash digest analyzer that processes data streams and extracts hash values in various byte orderings and formats. The analyzer should handle binary digest representations and provide utilities for converting between different byte order formats.
Implement a module that provides the following capabilities:
Hash Computation: Compute hashes for given byte data using 64-bit hash algorithms
Binary Digest Extraction: Extract hash digests as raw binary bytes
Byte Order Conversion: Convert hash digest bytes between big-endian and little-endian representations
Digest Comparison: Compare hash digests in their binary form to verify data integrity
Create a function compute_digest(data: bytes) -> bytes that:
Create a function swap_endianness(digest: bytes) -> bytes that:
Create a function compare_digests(data: bytes, expected_little_endian_hex: str) -> bool that:
Create the following files:
digest_analyzer.py: Main implementation moduletest_digest_analyzer.py: Test file with test casesInput:
data = b"hello world"
digest = compute_digest(data)Expected Output: The digest should be 8 bytes long (64-bit hash) and returned as a bytes object.
Validation:
assert len(digest) == 8
assert isinstance(digest, bytes)Input:
# Big-endian digest (example)
big_endian = b'\x01\x02\x03\x04\x05\x06\x07\x08'
little_endian = swap_endianness(big_endian)Expected Output:
little_endian == b'\x08\x07\x06\x05\x04\x03\x02\x01'Input:
data = b"test data"
# Compare against a known little-endian hex string
result = compare_digests(data, "c394c5c28df8b07e")Expected Output:
# Should return True when the computed digest
# (converted to little-endian) matches the expected value
assert isinstance(result, bool)Provides fast non-cryptographic hash functions with support for binary digest output.
Install with Tessl CLI
npx tessl i tessl/pypi-xxhashdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10