Skip to content

Comments

Add FNV-1a hash algorithm implementation with 32-bit and 64-bit variants#13814

Open
dinilH wants to merge 1 commit intoTheAlgorithms:masterfrom
dinilH:master
Open

Add FNV-1a hash algorithm implementation with 32-bit and 64-bit variants#13814
dinilH wants to merge 1 commit intoTheAlgorithms:masterfrom
dinilH:master

Conversation

@dinilH
Copy link

@dinilH dinilH commented Oct 30, 2025

Description

Add FNV-1a (Fowler-Noll-Vo) hash algorithm implementation to the hashes module.

Changes

  • Add hashes/fnv1a.py with two functions:
    • fnv1a_32(): 32-bit FNV-1a hash
    • fnv1a_64(): 64-bit FNV-1a hash

Why this contribution?

  • FNV-1a is a widely-used, fast, non-cryptographic hash function
  • Missing from the current hash algorithms collection
  • Educational value for understanding hash function design
  • Better distribution properties than original FNV-1

Testing

  • ✅ All 20 doctests pass
  • ✅ Tested with various inputs (empty string, single char, long strings)
  • ✅ Verified consistency (same input → same output)
  • ✅ Verified differentiation (different inputs → different outputs)
  • ✅ Type checking with mypy passes
  • ✅ Code style checks with ruff pass

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants