The siphash24 library provides a C-based, streaming-capable implementation of SipHash-1-3 and SipHash-2-4 variants for Python. It offers an interface compatible with Python's standard `hashlib` module, enhancing it with an `intdigest()` method for integer hash values. The current version is 1.8, with releases occurring several times a year to support new Python versions and address minor updates.
pip install siphash24Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to use both SipHash-2-4 (streaming) and SipHash-1-3 (one-shot) variants. It highlights the `hashlib`-compatible interface methods (`update`, `digest`, `hexdigest`) and the library's extended `intdigest` method. Keys are managed via environment variables for security best practice.
Use `hash_obj.digest()` for `bytes` output or `hash_obj.intdigest()` for `int` output.
Update your code to expect a `str` return type from `hexdigest()`. If you need `bytes`, encode the string manually (e.g., `.encode('utf-8')`).Use a separate hash object per thread or implement explicit locking mechanisms when sharing hash objects across threads.
Always provide a 16-byte key as a `bytes-like` object. For example, `b'your_16_byte_key'`.
Run `pip install siphash24` in your terminal to install the library.
Encode the string to bytes before passing it to `update()`, for example, `data.encode('utf-8')`.Ensure the key is exactly 16 bytes long. You can generate a secure random key using `os.urandom(16)` or pad/truncate an existing key.
Correct the import statement to `import siphash24` or `from siphash24 import new`.