xxhash is a Python binding for the high-performance, non-cryptographic xxHash library by Yann Collet. It is widely favored for its speed and efficiency in applications requiring fast hashing of large volumes of data, such as data integrity checks, file deduplication, and checksum generation. The library is actively maintained, with version 3.6.0 currently available, and new releases occurring a few times a year, often to support newer Python versions and xxHash upstream updates.
pip install xxhashVerified import paths — ran on the pinned version, not inferred.
This example demonstrates both one-shot and incremental hashing using the `xxh64` and `xxh3_128` algorithms. Data must be provided as bytes. An optional seed can be used to generate distinct hash outputs for identical input data.
Upgrade to Python 3.7+ or pin `xxhash<3.3.0`.
Ensure your environment or bundled C library meets the version requirement if building from source. For new code, consider using XXH3 algorithms for better performance.
Avoid using `xxhash.VERSION_TUPLE`. Use `xxhash.VERSION` for the module version string.
Use cryptographic hash functions (e.g., from Python's `hashlib` module) for security-sensitive contexts.
Ensure the `seed` value is a non-negative integer within the valid range for the chosen hash function (0 to 2^32-1 for xxh32, 0 to 2^64-1 for xxh64).
If migrating from a pre-0.3.0 version and relying on `digest()` byte order, update logic to expect big-endian. For new code, this is the default and expected behavior.
pip install xxhash
Encode the string to bytes before hashing, for example: `xxhash.xxh64('hello world'.encode('utf-8'))`Download and install the "Build Tools for Visual Studio" from the provided link, ensuring the "Desktop development with C++" workload or just the C++ build tools are selected during installation.
Call `xxh64()` with the data to get a hasher instance, then call `hexdigest()` on that instance: `xxhash.xxh64(b'data').hexdigest()`
No dependency data recorded yet.