{"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":"python","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,"search_vec":"'-1':22 '0.2.1':51 '100':57 '1a':26 'activ':45 'applic':41 'checksum':68 'correct':55 'coverag':59 'cryptograph':39 'current':49 'famili':19 'fnv':1,12,21,25,60 'fnv-1a':24 'fnv1':63 'fnv1a':64 'fnvhash':4 'focus':53 'fowler':14 'fowler-noll-vo':13 'function':18 'hash':2,17,40,61,62 'implement':3,9 'includ':20 'known':30 'librari':43 'maintain':46 'noll':15 'non':38 'non-cryptograph':37 'pure':7,66 'pure-python':65 'python':8,67 'simplic':33 'speed':35 'test':58 'variant':27 'version':50 'vo':16","created_at":"2026-04-15T18:36:54.157792+00:00","updated_at":"2026-04-16T15:10:19.507769+00:00","problems":[{"fix":"pip install fnvhash","cause":"The fnvhash library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'fnvhash'"},{"fix":"Encode the string to bytes before passing it to the hash function, for example: `data.encode('utf-8')`.","cause":"The fnvhash hashing functions expect byte strings as input, but a regular Python string was provided.","error":"TypeError: a bytes-like object is required, not 'str'"},{"fix":"Import specific hash functions directly from the fnvhash module, such as: `from fnvhash import fnv1a_32, fnv1_64`.","cause":"The user attempted to use a module or object named 'fnv' which is not the correct import name for the library, or did not import the specific functions from 'fnvhash'.","error":"NameError: name 'fnv' is not defined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/znerol/py-fnvhash","docs":null,"changelog":null,"pypi":"https://pypi.org/project/fnvhash/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}