Skip to content

Conversation

@rodrigobnogueira
Copy link

@rodrigobnogueira rodrigobnogueira commented Dec 25, 2025

Description

Implements the CRC32 (Cyclic Redundancy Check 32-bit) hash algorithm, which is widely used for error detection and data integrity verification.

Changes

  • Added hashes/crc32.py with complete implementation
  • Uses IEEE 802.3 polynomial (0xEDB88320)
  • Optimized with pre-calculated lookup table
  • 17 comprehensive doctests including edge cases
  • Cross-validated against Python's zlib.crc32()

Real-world Applications

  • ZIP file format
  • Ethernet frames
  • PNG images
  • GZIP compression
  • Data integrity verification
  • Error detection in network protocols

References

Testing

  • All 17 doctests pass
  • Passes ruff linting
  • Passes mypy type checking
  • Validated correctness against standard library zlib.crc32()

Checklist

  • I have read and followed the contributing guidelines
  • This pull request is not a duplicate
  • The algorithm is implemented from scratch
  • The code follows the repository style
  • I have read CONTRIBUTING.md
  • This pull request is all my own work -- I have not plagiarized
  • I know that pull requests will not be merged if they fail the automated tests
  • This PR only changes one algorithm file
  • All new Python files are placed inside an existing directory (hashes/)
  • All filenames are in all lowercase characters with no spaces or dashes
  • All functions and variable names follow Python naming conventions
  • All function parameters and return values are annotated with Python type hints
  • All functions have doctests that pass the automated testing
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation

- Implement CRC32 with IEEE 802.3 polynomial
- Add 17 comprehensive doctests with edge cases
- Include validation against zlib.crc32()
- Full type hints and English documentation
- Passes ruff and mypy checks

CRC32 is widely used in ZIP, Ethernet, PNG for data integrity.
This adds an important non-cryptographic hash algorithm
that was missing from the repository.
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.

1 participant