{"id":6647,"library":"fnvhash","title":"FNV Hash Implementation","description":"fnvhash is a pure Python implementation of the FNV (Fowler-Noll-Vo) hash function family, including FNV-1 and FNV-1a variants. It is known for its simplicity and speed in non-cryptographic hashing applications. The library is actively maintained, with its current version 0.2.1, and focuses on correctness with 100% test coverage.","status":"active","version":"0.2.1","language":"en","source_language":"en","source_url":"https://github.com/znerol/py-fnvhash","tags":["fnv","hash","hashing","fnv1","fnv1a","pure-python","checksum"],"install":[{"cmd":"pip install fnvhash","lang":"bash","label":"Install fnvhash"}],"dependencies":[],"imports":[{"note":"Imports the 32-bit FNV-1a hash function.","symbol":"fnv1a_32","correct":"from fnvhash import fnv1a_32"},{"note":"Imports the 64-bit FNV-1 hash function.","symbol":"fnv1_64","correct":"from fnvhash import fnv1_64"}],"quickstart":{"code":"from fnvhash import fnv1a_32, fnv1_64\n\ndata_str = \"hello world\"\ndata_bytes = data_str.encode('utf-8') # FNV hash functions expect bytes\n\n# Calculate 32-bit FNV-1a hash\nhash_32 = fnv1a_32(data_bytes)\nprint(f\"FNV-1a 32-bit hash of '{data_str}': {hex(hash_32)}\")\n\n# Calculate 64-bit FNV-1 hash\nlong_data_str = \"this is a slightly longer string for 64-bit hashing\"\nlong_data_bytes = long_data_str.encode('utf-8')\nhash_64 = fnv1_64(long_data_bytes)\nprint(f\"FNV-1 64-bit hash of '{long_data_str}': {hex(hash_64)}\")","lang":"python","description":"This quickstart demonstrates how to import and use the 32-bit FNV-1a and 64-bit FNV-1 hash functions. It highlights the requirement for input data to be `bytes` objects."},"warnings":[{"fix":"Do not use FNV hash functions for security-sensitive applications. Use `hashlib.sha256` or similar.","message":"FNV hashes are NOT cryptographically secure. They are designed for speed and distribution (e.g., hash tables, checksums), not for security-sensitive applications where resistance to malicious attacks or collision engineering is required. Use cryptographic hash functions like SHA-256 for security needs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure all input data is encoded to `bytes` (e.g., `my_string.encode('utf-8')`) before passing it to the hash function.","message":"The FNV hash functions (`fnv1a_32`, `fnv1_64`, etc.) expect `bytes` objects as input, not Python `str` objects. Passing a string directly will result in a TypeError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For maximum performance, consider using alternative libraries that provide C implementations of FNV hashing, such as `fnvhash-c` or `fnv-hash-fast` (which can fall back to pure Python `fnvhash`).","message":"This `fnvhash` library is a pure Python implementation. While portable, it may be significantly slower than C-extension based FNV hash libraries (e.g., `pyhash`, `fnvhash-c`) for performance-critical applications or large data sets.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your environment uses Python 3.9 or a newer compatible version.","message":"The library requires Python 3.9 or newer. Attempts to install or run on older Python versions (e.g., Python 3.8 or 2.x) will fail.","severity":"breaking","affected_versions":"<=0.2.1"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}